阅读:780回复:0
带vi的加解密
//加密
public function makesign($content,$secretKey){ //$secretKey = "your secret key"; $iv = substr($secretKey, 0, 16); //$content = "the original text that needs to be encrypted"; $encrypted = substr(sha1(microtime()), 0, 9). bin2hex(openssl_encrypt($content, 'aes-256-cbc', $secretKey, OPENSSL_RAW_DATA, $iv)). substr(sha1(microtime()), 0, 9); return $encrypted; } //解密 public function design($content,$secretKey){ $iv = substr($secretKey, 0, 16); //$content = "this is the ciphertext content"; $decrypted = openssl_decrypt(hex2bin(substr($content,9,-9)), 'aes-256-cbc', $secretKey, OPENSSL_RAW_DATA, $iv); return $decrypted; } |
|