PHP Blowfish 算法的加密解密,供大家参考,具体内容如下
<"htmlcode"><"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程序设计有所帮助。
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“php blowfish加密解密算法”评论...
P70系列延期,华为新旗舰将在下月发布
3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。
而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?
根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。