麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學院 > 邏輯算法 > 正文

php blowfish加密解密算法

2020-03-22 19:51:33
字體:
來源:轉載
供稿:網友
$size = mcrypt_get_block_size(MCRYPT_BLOWFISH, MCRYPT_MODE_CBC); $str = $this- pkcs5_pad($str, $size); if (mcrypt_generic_init($cipher, $this- key, $this- iv) != -1) $cipherText = mcrypt_generic($cipher, $str); mcrypt_generic_deinit($cipher); return base64_encode($cipherText); mcrypt_module_close($cipher); * blowfish + cbc模式 + pkcs5 解密 去補碼 * @param string $str 加密的數據 * @return string 解密的數據 html' target='_blank'>public function blowfish_cbc_pkcs5_decrypt($str) $cipher = mcrypt_module_open(MCRYPT_BLOWFISH, '', MCRYPT_MODE_CBC, ''); if (mcrypt_generic_init($cipher, $this- key, $this- iv) != -1) $cipherText = mdecrypt_generic($cipher, base64_decode($str)); mcrypt_generic_deinit($cipher); return $this- pkcs5_unpad($cipherText); mcrypt_module_close($cipher); private function pkcs5_pad($text, $blocksize){ $pad = $blocksize - (strlen ( $text ) % $blocksize); return $text . str_repeat ( chr ( $pad ), $pad ); private function pkcs5_unpad($str){ $pad = ord($str[($len = strlen($str)) - 1]); return substr($str, 0, strlen($str) - $pad);}BlowFish加密算法在php的使用第二例
$cipher = mcrypt_module_open(MCRYPT_BLOWFISH, '', MCRYPT_MODE_CBC, ''); // The block-size of the Blowfish algorithm is 64-bits, therefore our IV // is always 8 bytes: $iv = '12345678'; $key256 = '1234567890123456ABCDEFGHIJKLMNOP'; $key128 = '1234567890123456'; printf("iv: %s/n",bin2hex($iv)); printf("key256: %s/n",bin2hex($key256)); printf("key128: %s/n",bin2hex($key128)); $cleartext = 'The quick brown fox jumped over the lazy dog'; printf("clearText: %s/n/n",$cleartext); // Do 256-bit blowfish encryption: // The strengh of the encryption is determined by the length of the key // passed to mcrypt_generic_init if (mcrypt_generic_init($cipher, $key256, $iv) != -1) // PHP pads with NULL bytes if $cleartext is not a multiple of the block size.. $cipherText = mcrypt_generic($cipher,$cleartext ); mcrypt_generic_deinit($cipher); // Display the result in hex. printf("256-bit blowfish encrypted:/n%s/n/n",bin2hex($cipherText)); // 128-bit blowfish encryption: if (mcrypt_generic_init($cipher, $key128, $iv) != -1) // PHP pads with NULL bytes if $cleartext is not a multiple of the block size.. $cipherText = mcrypt_generic($cipher,$cleartext ); mcrypt_generic_deinit($cipher); // Display the result in hex. printf("128-bit blowfish encrypted:/n%s/n/n",bin2hex($cipherText)); // ------- // Results // ------- // You may use these as test vectors for testing your Blowfish implementations... // iv: 3132333435363738 // key256: 313233343536373839303132333435364142434445464748494a4b4c4d4e4f50 // key128: 31323334353637383930313233343536 // clearText: The quick brown fox jumped over the lazy dog // 256-bit blowfish encrypted: // 276855ca6c0d60f7d9708210440c1072e05d078e733b34b4198d609dc2fcc2f0c30926cdef3b6d52baf6e345aa03f83e // 128-bit blowfish encrypted: // d2b5abb73208aea3790621d028afcc74d8dd65fb9ea8e666444a72523f5ecca60df79a424e2c714fa6efbafcc40bdca0 以上就是本文的全部內容,希望對大家學習php程序設計有所幫助。PHP教程

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 毛片在线免费 | 精品国产一区二区三区久久久蜜月 | 97视频| 91一级毛片 | www.成人免费视频 | 久久精品观看 | 久久精品亚洲欧美日韩精品中文字幕 | 亚洲啊v在线观看 | 高清国产在线 | 欧美日韩免费观看视频 | 亚洲免费永久 | 羞羞网站视频 | 在线亚洲免费视频 | 免费看性xxx高清视频自由 | 91精品国产综合久久久动漫日韩 | 中国产一级毛片 | 国产亚洲欧美在线视频 | 在线播放的av网站 | 欧美成人综合视频 | 亚洲精品一区二区三区免 | 亚洲电影在线观看高清免费 | 成人片免费视频 | 七首小情歌泰剧在线播放 | 在线观看一二区 | av最新在线观看 | 精品一二三区视频 | 欧美精品免费一区二区三区 | 成人小视频免费在线观看 | 激情宗合 | 国产精品久久久久久久久久三级 | 色婷婷久久久久久 | 欧美成年人视频在线观看 | 91久久国产露脸精品免费 | 精品国产一区三区 | 伊人99在线 | 欧美一级不卡视频 | 色综合久久久久久 | 中文字幕一区二区三区久久 | 国产在线精品91 | 午夜国产小视频 | 亚洲精品自在在线观看 |