av国产剧情md精品麻豆,免费啪视频在线观看视频久18,特黄a又粗又大又黄又爽A片,国产av天堂

以文本方式查看主題

-  西安網(wǎng)站建設(shè)|西安網(wǎng)站制作|西安做網(wǎng)站_網(wǎng)站知識交流論壇  (http://china-ychdzx.com/bbs/index.asp)
--  網(wǎng)絡(luò)編程學(xué)習(xí)  (http://china-ychdzx.com/bbs/list.asp?boardid=5)
----  [分享]實現(xiàn)php加密/解密代碼  (http://china-ychdzx.com/bbs/dispbbs.asp?boardid=5&id=154)

--  作者:longlong
--  發(fā)布時間:2010/1/4 12:56:55
--  [分享]實現(xiàn)php加密/解密代碼

php加密/解密代碼

 

php中怎么實現(xiàn)加密和怎么實現(xiàn)解密里。其實很簡單。php有很多函數(shù)給大家用。今天就簡單的寫一段代碼給大家。代碼入邪 以下是代碼片段:
<?php
$key = "china-ychdzx.com!!!";
function keyED($txt,$encrypt_key)
{
$encrypt_key = md5($encrypt_key);
$ctr=0;
$tmp = "";
for ($i=0;$i<strlen($txt);$i++)
{
if ($ctr==strlen($encrypt_key)) $ctr=0;
$tmp.= substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1);
$ctr++;
}
return $tmp;
}
function encrypt($txt,$key)
{
srand((double)microtime()*1000000);
$encrypt_key = md5(rand(0,32000));
$ctr=0;
$tmp = "";
for ($i=0;$i<strlen($txt);$i++)
{
if ($ctr==strlen($encrypt_key)) $ctr=0;
$tmp.= substr($encrypt_key,$ctr,1) .
(substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1));
$ctr++;
}
return keyED($tmp,$key);
}
function decrypt($txt,$key)
{
$txt = keyED($txt,$key);
$tmp = "";
for ($i=0;$i<strlen($txt);$i++)
{
$md5 = substr($txt,$i,1);
$i++;
$tmp.= (substr($txt,$i,1) ^ $md5);
}
return $tmp;
}

使用測試:
$string = "029900.com!!!";
//加密并把加密的值給$enc_text
$enc_text = encrypt($string,$key);
//解密并把加密的值給$dec_text

$dec_text = decrypt($enc_text,$key);

//打。
print "Original text : $string <Br>";
print "Encrypted text : $enc_text <Br>";
print "Decrypted text : $dec_text <Br>";
?>