欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php自定義加密與解密程序?qū)嵗?/h1>
 更新時(shí)間:2014年12月31日 14:41:48   投稿:shichen2014  
這篇文章主要介紹了php自定義加密與解密程序,實(shí)例分析了自定義加密解密類文件及相關(guān)用法,具有一定參考借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了php自定義加密與解密程序。分享給大家供大家參考。具體分析如下:

PHP3 Cryption是一個(gè)非常容易被破解,不安全的加密功能,不應(yīng)該是非常重要的東西用,雖然加密是好的,它不會(huì)阻礙對(duì)尖端開裂程序的嚴(yán)格考驗(yàn).

不過,試試吧...這是一個(gè)偉大的方式來加密和解密字符串。與許多隱窩功能,這是雙向的。基于一個(gè)密碼,您可以加密或解密。您也可以解密或加密過無數(shù)次,通過循環(huán)或其他方法。字母表中的字符也是變化的。所有這些事情讓你修改和鞏固加密。

關(guān)于這最佳的部分?您可以加密與解密或一張紙和一支鉛筆一塊。這需要相當(dāng)長(zhǎng)一點(diǎn),但你并不需要一臺(tái)電腦是附近使用它,如果你曾經(jīng)失去的代碼,如果你還記得你的技術(shù)可以解密。

我寫在約一小時(shí)這些功能,經(jīng)過幾次不成功的和令人沮喪的嘗試,并獲得了更長(zhǎng)的時(shí)間我沒有出路的。成功的那天后的最佳方式做它突然實(shí)現(xiàn)。

請(qǐng)注意,這不會(huì)加密/解密無形字符(空格),如換行符(n)或標(biāo)簽(噸)!很抱歉,但我嘗試,如果你找到一個(gè)辦法,請(qǐng)讓我知道!

復(fù)制代碼 代碼如下:
$ralphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 !,.:;?~@#$%^&*()_+-=][}{/><"'"; 
$alphabet = $ralphabet . $ralphabet;
 
class Crypto {
 
function encrypt ($password,$strtoencrypt) {
 
global $ralphabet; 
global $alphabet;
 
for( $i=0; $i<strlen($password); $i++ ) 

$cur_pswd_ltr = substr($password,$i,1); 
$pos_alpha_ary[] = substr(strstr($alphabet,$cur_pswd_ltr),0,strlen($ralphabet)); 
}
 
$i=0; 
$n = 0; 
$nn = strlen($password); 
$c = strlen($strtoencrypt);
 
while($i<$c) 

$encrypted_string .= substr($pos_alpha_ary[$n],strpos($ralphabet,substr($strtoencrypt,$i,1)),1);
 
$n++; 
if($n==$nn) $n = 0; 
$i++; 
}
 
return $encrypted_string;
 
}
 
function decrypt ($password,$strtodecrypt) {
 
global $ralphabet; 
global $alphabet;
 
for( $i=0; $i<strlen($password); $i++ ) 

$cur_pswd_ltr = substr($password,$i,1); 
$pos_alpha_ary[] = substr(strstr($alphabet,$cur_pswd_ltr),0,strlen($ralphabet)); 
}
 
$i=0; 
$n = 0; 
$nn = strlen($password); 
$c = strlen($strtodecrypt);
 
while($i<$c) 

$decrypted_string .= substr($ralphabet,strpos($pos_alpha_ary[$n],substr($strtodecrypt,$i,1)),1);
 
$n++; 
if($n==$nn) $n = 0; 
$i++; 
}
 
return $decrypted_string;
 
}
 
function cryption_table ($password) {
 
global $ralphabet; 
global $alphabet;
 
for( $i=0; $i<strlen($password); $i++ ) 

$cur_pswd_ltr = substr($password,$i,1); 
$pos_alpha_ary[] = substr(strstr($alphabet,$cur_pswd_ltr),0,strlen($ralphabet)); 
}
 
print "<table border=1 cellpadding="0" cellspacing="0">n";
 
print "<tr><td></td>"; 
for( $j=0; $j<strlen($ralphabet); $j++ ) 

print "<td align="center"><font size="2" face="arial">" . substr($ralphabet,$j,1) . "</td>n"; 

print "</tr>";
 
 
for( $i=0; $i<count($pos_alpha_ary); $i++ ) 

print "<tr><td align="right"><font size="2"><b>" . ($i+1) . "|</b></font></td>"; 
for( $k=0; $k<strlen($pos_alpha_ary[$i]); $k++ ) 

print "<td align="center"><font size="2" face="arial">" . substr($pos_alpha_ary[$i],$k,1) . "</td>n"; 

print "</tr>"; 
}
 
print "</table>n";
 
}
 
} // end class Crypto
 
// Example written by Macro Zeng 
$ct = new Crypto; 
//$ct->cryption_table($password); 
echo "<form action=$PHP_SELF method=post>"; 
if ($mod == 2) { 
$strtodecrypt = $ct->encrypt ($password,$strtoencrypt); 
echo 'Encrypted String(加密后的字段): '; 
echo "<input type=text name=strtodecrypt size=45 value=$strtodecrypt>"; 
echo "密碼鎖: <input type=text name=password size=6 value=$password>"; 
echo "<input type=submit value="Decrypt(解密)">"; 

else { 
$strtoencrypt = $ct->decrypt ($password,$strtodecrypt); 
echo 'String to Encrypt(需要加密的字段): '; 
echo "<input type=text name=strtoencrypt size=45 value=$strtoencrypt>"; 
echo "密碼鎖: <input type=text name=password size=6 value=$password>"; 
echo "<input type=submit value="Encrypt(加密)">"; 
echo "<input type=hidden name=mod value=2>"; 

echo "</form>";

復(fù)制代碼 代碼如下:

highlight_file("crypto.php");

希望本文所述對(duì)大家的php程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論