この投稿は xuzuning によって最終編集されました: 2013-02-21 10:07:35
これで、次のように復号化関数 (readkey) が分かりました。対応する暗号化関数
<br>
function authcode( $string, $operation = "DECODE", $key = "", $expiry = 0 )<br>
{<br>
$ckey_length = 4;<br>
$key = md5( $key != "" ? $key : "a2264dxLupVMlkqR" );<br>
$keya = md5(substr( $key, 0, 16 ) );<br>
$keyb = md5(substr( $key, 16, 16 ) );<br>
$keyc = $ckey_length ? $operation == "DECODE" ? substr( $string, 0, $ckey_length ) : substr( md5( microtime( ) ), 0 - $ckey_length ) : "";<br>
$cryptkey = $keya.md5( $keya.$keyc );<br>
$key_length = strlen( $cryptkey );<br>
$string = $operation == "DECODE" ?base64_decode(substr( $string, $ckey_length ) ) : sprintf( " 0d", $expiry ? $expiry time( ) : 0 ).substr( md5( $string.$ keyb ), 0, 16 ).$string;<br>
$string_length = strlen( $string );<br>
$result = "";<br>
$box = range( 0, 255 );<br>
$rndkey = array( );<br>
$i = 0;<br>
for ( ; $i
{<br>
$rndkey[$i] = ord( $cryptkey[$i % $key_length] );<br>
}<br>
$j = $i = 0;<br>
for ( ; $i
{<br>
$j = ( $j $box[$i] $rndkey[$i] ) % 256;<br>
$tmp = $box[$i];<br>
$box[$i] = $box[$j];<br>
$box[$j] = $tmp;<br>
}<br>
$a = $j = $i = 0;<br>
for ( ; $i
{<br>
$a = ( $a 1 ) % 256;<br>
$j = ( $j $box[$a] ) % 256;<br>
$tmp = $box[$a];<br>
$box[$a] = $box[$j];<br>
$box[$j] = $tmp;<br>
$result .= chr( ord( $string[$i] ) ^ $box[( $box[$a] $box[$j] ) % 256] );<br>
}<br>
if ( $operation == "DECODE" )<br>
{<br>
if ( ( substr( $result, 0, 10 ) == 0 || 0 < substr( $result, 0, 10 ) - time( ) ) && substr( $result, 10, 16 ) == substr( md5( substr( $result, 26 ).$keyb ), 0, 16 ) )<br>
{<br>
return substr( $result, 26 );<br>
}<br>
"" を返します;<br>
}<br>
return $keyc.str_replace( "=", "",base64_encode( $result ) );<br>
}<br>
関数 readkey( $keys )<br>
{<br>
$Leskey = authcode( $keys, "DECODE", "a2264dxLupVMlkqR" );<br>
$Leskey =base64_decode( $Leskey );<br>
$firstStr = substr( $Leskey, 0, 1 );<br>
$Leskey = substr( $Leskey, 1 );<br>
$Leskey = strrev( substr( $Leskey, 0, $firstStr ) ).chr( ord( substr( $Leskey, $firstStr, 1 ) ) ^ $firstStr ).strrev( substr( $Leskey, $firstStr 1 ) ); <div class="clear"></div>
ログイン後にコピー