您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

PHP blowfish 加密解密函数

2024/3/17 14:52:59发布39次查看
跳至 [1] [全屏预览] 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 解密的数据 */ 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); }}
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product