PHP3 Cryption是一個非常容易被破解,不安全的加密功能,不應該是非常重要的東西用,雖然加密是好的,它不會阻礙對尖端開裂程序的嚴格考驗.
不過,試試吧...這是一個偉大的方式來加密和解密字符串。與許多隱窩功能,這是雙向的。基于一個密碼,您可以加密或解密。您也可以解密或加密過無數次,通過循環或其他方法。字母表中的字符也是變化的。所有這些事情讓你修改和鞏固加密。
關于這最佳的部分?您可以加密與解密或一張紙和一支鉛筆一塊。這需要相當長一點,但你并不需要一臺電腦是附近使用它,如果你曾經失去的代碼,如果你還記得你的技術可以解密。
我寫在約一小時這些功能,經過幾次不成功的和令人沮喪的嘗試,并獲得了更長的時間我沒有出路的。成功的那天后的最佳方式做它突然實現。
請注意,這不會加密/解密無形字符(空格),如換行符(n)或標簽(噸)!很抱歉,但我嘗試,如果你找到一個辦法,請讓我知道!
- * /
- highlight_file(“crypto.php”);
- $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
- // 網絡技術主管座右銘:三人行其必有我師焉。http://m.survivalescaperooms.com
- $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>//開源代碼Vevb.com
- ";
- 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>";
新聞熱點
疑難解答