Witajcie znalazłem małą klasę w manualu, przerobiłem sobie tylko klucz na stały w klasie ( był w konstruktorze)
wydaje mi się bardzo fajnym sposobem na szyfrowanie danych w bazie pokroju adres e-mail itp. co o tym powiecie?
class Crypt {
private $securekey='klucz 32 :)';
private $iv;
function __construct($textkey) {
$this->securekey = hash('sha256',$textkey,TRUE);
$this->iv = mcrypt_create_iv(32);
}
function encrypt($input) {
return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->securekey, $input, MCRYPT_MODE_ECB, $this->iv));
}
function decrypt($input) {
return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->securekey, base64_decode($input), MCRYPT_MODE_ECB, $this->iv));
}
}