Php5.5 provides more reliable and convenient encryption methods. For more information, see:
Password_hash ()
Http://www.php.net/manual/zh/function.password-hash.php
Two string encryption and decryption algorithms based on the mcrypt Extension
<? Php/*** @ info string encryption and decryption algorithm 1. Use mcrypt extension * @ param string $ string to be processed * $ action ENCODE, encryption | DECODE, decryption * @ return string $ returnstr * @ date 2014/4/22 * @ author tonglei */function mcrypt_handle_string ($ string, $ action = 'encoding '){! Is_array ($ string) or exit; $ action = 'decode' & $ string = base64_decode ($ string); $ key = "123456 "; // key can be customized or obtained in the configuration file $ mcryptAlgorithm = MCRYPT_DES; // select an encryption algorithm $ mcryptMode = MCRYPT_MODE_ECB; // select an encryption mode $ mcryptIv = mcrypt_create_iv (encrypt ($ encrypt, $ mcryptMode), MCRYPT_RAND); // create an initialization vector $ returnstr = base64_encode (encrypt ($ mcryptAlgorithm, $ key, $ string, $ mcryptMode, $ mcryptIv); if ('decode' = $ action) {$ returnstr = mcrypt_decrypt ($ mcryptAlgorithm, $ key, $ string, $ mcryptMode, $ mcryptIv);} return $ returnstr ;}
<? Php/*** @ info string encryption and decryption algorithm 2 adopts bitwise XOR or * @ param string $ string to be processed * @ param $ action ENCODE encryption | DECODE decryption * @ return string */function StrCode ($ string, $ action = 'encoding') {$ action! = 'Encode' & $ string = base64_decode ($ string); $ code = ''; $ key = substr (md5 ($ GLOBALS ['pwserver'] ['HTTP _ USER_AGENT ']. $ GLOBALS ['db _ hash']), 8, 18); $ keyLen = strlen ($ key); $ strLen = strlen ($ string ); for ($ I = 0; $ I <$ strLen; $ I ++) {$ k = $ I % $ keyLen; $ code. = $ string [$ I] ^ $ key [$ k];} return ($ action! = 'Decode '? Base64_encode ($ code): $ code );}