There are more reliable and convenient encryption methods in the php5.5. A friend who likes to delve into the study:
Password_hash ()
http://www.php.net/manual/zh/function.password-hash.php
Two string encryption and decryption algorithms based on MCrypt extension, bitwise XOR or summary
Php/** * @info string encryption and decryption algorithm one, using mcrypt extension * @param string $string pending String * $action ENCODE, encryption | DECODE, Decrypt * @return string $RETURNSTR * @date 2014/4/22 * @author tonglei*/functionMcrypt_handle_string ($string,$action= ' ENCODE '){ !Is_array($string) orExit; $action= = ' DECODE ' &&$string=Base64_decode($string); $key= "123456";//key can be customized or obtained in the configuration file $mcryptAlgorithm= Mcrypt_des;//Choosing a Cryptographic algorithm $mcryptMode= MCRYPT_MODE_ECB;//Select an encryption mode $mcryptIv= Mcrypt_create_iv (Mcrypt_get_iv_size ($mcryptAlgorithm,$mcryptMode),Mcrypt_rand); //creating an initialization vector $returnstr=Base64_encode(Mcrypt_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 using bitwise XOR or * @param string $string pending String * @param $action ENCODE Encryption | DECODE decryption * @return string*/functionStrcode ($string,$action= ' ENCODE '){ $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);}
http://www.bkjia.com/PHPjc/769761.html www.bkjia.com true http://www.bkjia.com/PHPjc/769761.html techarticle There are more reliable and convenient encryption methods in the php5.5. Like to delve into the friend can understand: Password_hash () http://www.php.net/manual/zh/function.password-hash.php based on mcrypt extension ...