The following script is from the seven cattle provided by the
$ echo -n [AES128KEY] | openssl rsautl -encrypt -oaep -inkey [QINIU_PUB_KEY_FILE] -pubin | openssl base64 -A | tr "+/" "-_"
I know that PHP has to provide openssl
modules, but I do not understand this module, I have no understanding of the friend, the above code is rewritten into PHP. Thank you so much.
Reply content:
The following script is from the seven cattle provided by the
$ echo -n [AES128KEY] | openssl rsautl -encrypt -oaep -inkey [QINIU_PUB_KEY_FILE] -pubin | openssl base64 -A | tr "+/" "-_"
I know that PHP has to provide openssl
modules, but I do not understand this module, I have no understanding of the friend, the above code is rewritten into PHP. Thank you so much.
class AES_128_CW { private $_iv = ''; private $_secret = ''; public function __construct($iv,$secret){ $this->_iv = substr($iv.'0000000000000000', 0,16);//可以忽略这一步,只要你保证iv长度是16 $this->_secret = hash('md5',$secret,true); } public function decode($secretData){ return openssl_decrypt(urldecode($secretData),'aes-128-cbc',$this->_secret,false,$this->_iv); } public function encode($data){ return urlencode(openssl_encrypt($data,'aes-128-cbc',$this->_secret,false,$this->_iv)); }
}