时间:2021-07-01 10:21:17 帮助过:19人阅读
- const<br> <br> XorKey:array[0..7] of Byte=($B2,$09,$AA,$55,$93,$6D,$84,$47); //字符串加密用<br> <br>function Dec(Str:String):String;//字符解密函數<br>var<br>i,j:Integer;<br>begin<br>Result:='';<br>j:=0;<br>for i:=1 to Length(Str) div 2 do<br> begin<br> Result:=Result+Char(StrToInt('$'+Copy(Str,i*2-1,2)) xor XorKey[j]);<br> j:=(j+1) mod 8;<br> end;<br>end;
F76DC321A1
- $XorKey = array(0xB2,0x09,0xAA,0x55,0x93,0x6D,0x84,0x47);<br><br>echo $s = enc('Edit2', $XorKey), PHP_EOL;<br><br>echo dec($s, $XorKey);<br><br>function Enc($Str, $XorKey) { //:String;//字符加密函數 這是用的一個異或加密<br> $Result = '';<br> $j = 0;<br> for($i=0; $i<strlen($str); $i++)="" {<br=""> $Result .= sprintf('%02X', ord($Str{$i}) ^ $XorKey[$j]);<br> $j = ($j+1) % 8;<br> }<br> return $Result;<br>}<br><br>function Dec($str, $XorKey){<br> $result = "";<br> for($i=0, $j=0; $i<strlen($str); $i+="2)" {<br=""> $result .= chr(hexdec($str{$i} . $str{$i+1}) ^ $XorKey[$j]);<br> $j = ++$j % 8;<br> }<br> return $result;<br>}<br></strlen($str);></strlen($str);>
- <br><!--?php<br /-->$XorKey = array(0xB2,0x09,0xAA,0x55,0x93,0x6D,0x84,0x47);<br>function Dec($str){<br> global $XorKey;<br> $result = "";<br> $j = 0;<br> for ($i = 0; $i < strlen($str)/2; $i++)<br> {<br> $result = $result . chr(hexdec($str[$i*2] . $str[$i*2+1]) ^ $XorKey[$j]);<br> $j = ++$j % 8;<br> }<br> return $result;<br>}<br><br><br>function Enc($str){<br>
- global $XorKey;<br>
- $result = "";<br>
- $j = 0;<br>
- for ($i = 0; $i < strlen($str); $i++)<br>
- {<br>
- $result = $result. dechex(ord($str[$i])^$XorKey[$j]);<br>
- $j = ++$j % 8;<br>
- }<br>
- return $result;<br>}<br>echo Enc("Edit2")."\n";<br>echo Dec("F76DC321A1");