例如
創(chuàng)新互聯(lián)服務(wù)項(xiàng)目包括海陽(yáng)網(wǎng)站建設(shè)、海陽(yáng)網(wǎng)站制作、海陽(yáng)網(wǎng)頁(yè)制作以及海陽(yáng)網(wǎng)絡(luò)營(yíng)銷(xiāo)策劃等。多年來(lái),我們專(zhuān)注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢(shì)、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,海陽(yáng)網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶(hù)以成都為中心已經(jīng)輻射到海陽(yáng)省份的部分城市,未來(lái)相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶(hù)的支持與信任!
public function desEncrypt($str,$key) { $iv = $key; $size = mcrypt_get_block_size ( MCRYPT_DES, MCRYPT_MODE_CBC ); $str = $this->_pkcs5_pad ( $str, $size ); return strtoupper( bin2hex( mcrypt_encrypt(MCRYPT_DES, $key, $str, MCRYPT_MODE_CBC, $iv ) ) ); } public function desDecrypt($str,$key) { $iv = $key; $strBin = $this->_hex2bin( strtolower( $str ) ); $str = mcrypt_decrypt( MCRYPT_DES, $key, $strBin, MCRYPT_MODE_CBC, $iv ); $str = $this->_pkcs5_unpad( $str ); return $str; } private function _pkcs5_pad($text,$block=8){ $pad = $block - (strlen($text) % $block); return $text . str_repeat(chr($pad), $pad); } private function _pkcs5_unpad($text) { $pad = ord($text{strlen($text)-1}); if ($pad > strlen($text)) return $text; if (strspn($text, chr($pad), strlen($text) - $pad) != $pad) return $text; return substr($text, 0, -1 * $pad); }
替換后:
//要改的加密 public function desEncrypt($str,$key) { // $b = openssl_get_cipher_methods(); // echo '<pre>'; // print_r($b); $iv = $key; // $size = mcrypt_get_block_size ( MCRYPT_DES, MCRYPT_MODE_CBC ); // var_dump($size);exit; // $str = $this->_pkcs5_pad ( $str, $size ); // return strtoupper( bin2hex( mcrypt_encrypt(MCRYPT_DES, $key, $str, MCRYPT_MODE_CBC, $iv ) ) ); $data = openssl_encrypt($str,"DES-CBC",$key,OPENSSL_RAW_DATA,$iv); $data = strtolower(bin2hex($data)); return $data; } //要改的解密 public function desDecrypt($str,$key) { $iv = $key; // $strBin = $this->_hex2bin( strtolower( $str ) ); // $str = mcrypt_decrypt( MCRYPT_DES, $key, $strBin, MCRYPT_MODE_CBC, $iv ); // $str = $this->_pkcs5_unpad( $str ); // return $str; return openssl_decrypt (hex2bin($str), 'DES-CBC', $key, OPENSSL_RAW_DATA,$iv); }
這些網(wǎng)上都有,在作者使用的過(guò)程中因?yàn)槭褂玫氖荕CRYPT_DES,無(wú)法得知openssl對(duì)應(yīng)的是那種加密方式,所以通過(guò)手冊(cè)找到了openssl_get_cipher_methods();該方法可以找出openssl支持的所有方法,進(jìn)行替換即可。
echo '<pre>'; $a = openssl_get_cipher_methods(); print_r($a); Array ( [0] => AES-128-CBC [1] => AES-128-CFB [2] => AES-128-CFB1 [3] => AES-128-CFB8 [4] => AES-128-CTR [5] => AES-128-ECB [6] => AES-128-OFB [7] => AES-128-XTS [8] => AES-192-CBC [9] => AES-192-CFB [10] => AES-192-CFB1 [11] => AES-192-CFB8 [12] => AES-192-CTR [13] => AES-192-ECB [14] => AES-192-OFB [15] => AES-256-CBC [16] => AES-256-CFB [17] => AES-256-CFB1 [18] => AES-256-CFB8 [19] => AES-256-CTR [20] => AES-256-ECB [21] => AES-256-OFB [22] => AES-256-XTS [23] => BF-CBC [24] => BF-CFB [25] => BF-ECB [26] => BF-OFB [27] => CAMELLIA-128-CBC [28] => CAMELLIA-128-CFB [29] => CAMELLIA-128-CFB1 [30] => CAMELLIA-128-CFB8 [31] => CAMELLIA-128-ECB [32] => CAMELLIA-128-OFB [33] => CAMELLIA-192-CBC [34] => CAMELLIA-192-CFB [35] => CAMELLIA-192-CFB1 [36] => CAMELLIA-192-CFB8 [37] => CAMELLIA-192-ECB [38] => CAMELLIA-192-OFB [39] => CAMELLIA-256-CBC [40] => CAMELLIA-256-CFB [41] => CAMELLIA-256-CFB1 [42] => CAMELLIA-256-CFB8 [43] => CAMELLIA-256-ECB [44] => CAMELLIA-256-OFB [45] => CAST5-CBC [46] => CAST5-CFB [47] => CAST5-ECB [48] => CAST5-OFB [49] => DES-CBC [50] => DES-CFB [51] => DES-CFB1 [52] => DES-CFB8 [53] => DES-ECB [54] => DES-EDE [55] => DES-EDE-CBC [56] => DES-EDE-CFB [57] => DES-EDE-OFB [58] => DES-EDE3 [59] => DES-EDE3-CBC [60] => DES-EDE3-CFB [61] => DES-EDE3-CFB1 [62] => DES-EDE3-CFB8 [63] => DES-EDE3-OFB [64] => DES-OFB [65] => DESX-CBC [66] => IDEA-CBC [67] => IDEA-CFB [68] => IDEA-ECB [69] => IDEA-OFB [70] => RC2-40-CBC [71] => RC2-64-CBC [72] => RC2-CBC [73] => RC2-CFB [74] => RC2-ECB [75] => RC2-OFB [76] => RC4 [77] => RC4-40 [78] => RC4-HMAC-MD5 [79] => SEED-CBC [80] => SEED-CFB [81] => SEED-ECB [82] => SEED-OFB [83] => aes-128-cbc [84] => aes-128-cfb [85] => aes-128-cfb1 [86] => aes-128-cfb8 [87] => aes-128-ctr [88] => aes-128-ecb [89] => aes-128-gcm [90] => aes-128-ofb [91] => aes-128-xts [92] => aes-192-cbc [93] => aes-192-cfb [94] => aes-192-cfb1 [95] => aes-192-cfb8 [96] => aes-192-ctr [97] => aes-192-ecb [98] => aes-192-gcm [99] => aes-192-ofb [100] => aes-256-cbc [101] => aes-256-cfb [102] => aes-256-cfb1 [103] => aes-256-cfb8 [104] => aes-256-ctr [105] => aes-256-ecb [106] => aes-256-gcm [107] => aes-256-ofb [108] => aes-256-xts [109] => bf-cbc [110] => bf-cfb [111] => bf-ecb [112] => bf-ofb [113] => camellia-128-cbc [114] => camellia-128-cfb [115] => camellia-128-cfb1 [116] => camellia-128-cfb8 [117] => camellia-128-ecb [118] => camellia-128-ofb [119] => camellia-192-cbc [120] => camellia-192-cfb [121] => camellia-192-cfb1 [122] => camellia-192-cfb8 [123] => camellia-192-ecb [124] => camellia-192-ofb [125] => camellia-256-cbc [126] => camellia-256-cfb [127] => camellia-256-cfb1 [128] => camellia-256-cfb8 [129] => camellia-256-ecb [130] => camellia-256-ofb [131] => cast5-cbc [132] => cast5-cfb [133] => cast5-ecb [134] => cast5-ofb [135] => des-cbc [136] => des-cfb [137] => des-cfb1 [138] => des-cfb8 [139] => des-ecb [140] => des-ede [141] => des-ede-cbc [142] => des-ede-cfb [143] => des-ede-ofb [144] => des-ede3 [145] => des-ede3-cbc [146] => des-ede3-cfb [147] => des-ede3-cfb1 [148] => des-ede3-cfb8 [149] => des-ede3-ofb [150] => des-ofb [151] => desx-cbc [152] => id-aes128-GCM [153] => id-aes192-GCM [154] => id-aes256-GCM [155] => idea-cbc [156] => idea-cfb [157] => idea-ecb [158] => idea-ofb [159] => rc2-40-cbc [160] => rc2-64-cbc [161] => rc2-cbc [162] => rc2-cfb [163] => rc2-ecb [164] => rc2-ofb [165] => rc4 [166] => rc4-40 [167] => rc4-hmac-md5 [168] => seed-cbc [169] => seed-cfb [170] => seed-ecb [171] => seed-ofb )
以上就是php7.2中mcrypt轉(zhuǎn)openssl的方法詳解的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注創(chuàng)新互聯(lián)其它相關(guān)文章!
新聞名稱(chēng):php中如何將mcrypt轉(zhuǎn)換成openssl?
分享鏈接:http://www.rwnh.cn/article42/ippdhc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)建站、網(wǎng)站制作、網(wǎng)站策劃、網(wǎng)站排名、云服務(wù)器、網(wǎng)站設(shè)計(jì)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)