您好,欢迎访问一九零五行业门户网

javascript - aes128加密一些相关问题

class aes {
const key = 625202f9149e061d;const iv = 5efd3f6060e20330;/**

pkcs7补码
@param string $string 明文
@param int $blocksize blocksize , 以 byte 为单位
@return string
*/
function addpkcs7padding($string, $blocksize = 32) {
$len = strlen($string); //取得字符串长度 $pad = $blocksize - ($len % $blocksize); //取得补码的长度 $string .= str_repeat(chr($pad), $pad); //用ascii码为补码长度的字符, 补足最后一段 return $string;

}
aes128cbcencrypt($str, $iv = self::iv, $key = self::key) { // $this->addpkcs7padding($str,16)
$base = (mcrypt_encrypt(mcrypt_rijndael_128, $key, $this->addpkcs7padding($str, 16), mcrypt_mode_cbc, $iv)); return $this->strtohex($base);

}
strtohex($string) {//字符串转十六进制
$hex = ; $tmp = ; for ($i = 0; $i

}
aes加密 在网上找的代码有php 和 android 的 来位好心人讲讲$aes = new aes(); $aes->aes128cbcencrypt('token');这个加密过程的每一步呗 或者帮忙写一份对应的js版本的 = =
回复内容: class aes {
const key = 625202f9149e061d;const iv = 5efd3f6060e20330;/**

pkcs7补码
@param string $string 明文
@param int $blocksize blocksize , 以 byte 为单位
@return string
*/
function addpkcs7padding($string, $blocksize = 32) {
$len = strlen($string); //取得字符串长度 $pad = $blocksize - ($len % $blocksize); //取得补码的长度 $string .= str_repeat(chr($pad), $pad); //用ascii码为补码长度的字符, 补足最后一段 return $string;

}
aes128cbcencrypt($str, $iv = self::iv, $key = self::key) { // $this->addpkcs7padding($str,16)
$base = (mcrypt_encrypt(mcrypt_rijndael_128, $key, $this->addpkcs7padding($str, 16), mcrypt_mode_cbc, $iv)); return $this->strtohex($base);

}
strtohex($string) {//字符串转十六进制
$hex = ; $tmp = ; for ($i = 0; $i

}
aes加密 在网上找的代码有php 和 android 的 来位好心人讲讲$aes = new aes(); $aes->aes128cbcencrypt('token');这个加密过程的每一步呗 或者帮忙写一份对应的js版本的 = =
说起来挺复杂的,你看看这个链接吧。
http://yinghuayuan8866.blog.163.com/blog/static/2245702720121225658625/
其它类似信息

推荐信息