php加密技术

1.效果展示:

php加密技术_第1张图片


2.实现技术:

<?php
header("content-type: text/html; charset=utf8" ) ;
$str="haoyunyun";
/*md5加密43af19c415c235264faf71b55463425c*/
echo md5($str);
echo "</br>";
/*crypt加密$1$jn/.wD3.$1A2At6cEpfQE1yJnvLszB.*/
echo crypt($str);
echo "</br>";
/*标准加密*/
echo crypt($str, '1408phpE');//14r6nfAAqYf3U;
echo "</br>";
/*sha1加密*/
echo sha1($str);
echo "</br>";
/*md5+shal加密*/
echo sha1(md5($str));
echo "</br>";
/*url编码技术加密*/
echo urlencode($str) ;
echo "</br>";
echo urldecode(urlencode($str) ) ;
echo "</br>";
$str1= "this + is + my + name" ;
echo rawurlencode($str1) ;
echo "</br>";
$str2 = "我的名字是云哥云一般人我不告诉他! " ; //加密内容
$key = "haoyunyun" ; //密钥 自己制定密钥
$cipher = MCRYPT_DES; //密码类型
$modes = MCRYPT_MODE_ECB; //密码模式
$iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher, $modes) , MCRYPT_RAND) ; //初始化向量
echo "加密明 文: " . $str2. "<p>" ;
@$str_encrypt =base64_encode( mcrypt_encrypt($cipher, $key, $str2, $modes, $iv) ) ; //加密函数
echo "加密密文: " . $str_encrypt. " <p>" ;
@$str_decrypt = mcrypt_decrypt($cipher, $key, base64_decode($str_encrypt) , $modes, $iv) ; //解密函数
echo "还原: " . $str_decrypt;
echo "</br>";

3.仅供参考。

你可能感兴趣的:(php加密技术)