Файл: core/openssl.class.php
Строк: 19
<?php
class OpenSSLCrypt
{
protected $secret_key;
protected $secret_iv;
public function __construct($secret_key, $secret_iv)
{
$this->secret_iv = substr(hash('sha256', $secret_iv), 0, 16);
$this->secret_key = hash('sha256', $secret_key);
}
public function crypt($string)
{
return base64_encode(openssl_encrypt($string, 'AES-256-CBC', $this->secret_key, 0, $this->secret_iv));
}
public function decrypt($string)
{
return openssl_decrypt(base64_decode($string), 'AES-256-CBC', $this->secret_key, 0, $this->secret_iv);
}
}