class Asetest
{
public $key = ‘8977d9f2bdd34c11ac822f891f0d5fa7’;
public $iv = '';
public $method = 'AES-256-ECB';
//加密
public function aesEn($data = 'edbf67091a8f4f32202206131708421.0'){
return base64_encode(openssl_encrypt($data, $this->method,$this->key, OPENSSL_RAW_DATA,$this->iv));
}
//解密
public function aesDe($data = 'OWRt8+sEO1uQfegv81DAc5u0RxZRhYASihvIsqUKBFcxRzdKE1cuPXVnjhJbH97C'){
return openssl_decrypt(base64_decode($data), $this->method, $this->key, OPENSSL_RAW_DATA,$this->iv);
}
}
PHP 7 需要 AES-256 即可