const XorKey:array[0..7] of Byte=($B2,$09,$AA,$55,$93,$6D,$84,$47); //字符串加密用 function Dec(Str:String):String;//字符解密函?vari,j:Integer;beginResult:='';j:=0;for i:=1 to Length(Str) div 2 do begin Result:=Result+Char(StrToInt('$'+Copy(Str,i*2-1,2)) xor XorKey[j]); j:=(j+1) mod 8; end;end;
解决了200分奉上
还有一个帖子也是100分: http://bbs.csdn.net/topics/390998635
给个密文,我测试看看~
<?php$XorKey = array(0xB2,0x09,0xAA,0x55,0x93,0x6D,0x84,0x47);function Dec($str){ global $XorKey; $result = ""; $j = 0; for ($i = 0; $i < strlen($str)/2 - 1; $i++) { $result = $result . chr(hexdec($str[$i*2] . $str[$i*2+1]) ^ $XorKey[$j]); $j = ++$j % 8; } return $result;}
function Dec($str){ $XorKey = array(0xB2,0x09,0xAA,0x55,0x93,0x6D,0x84,0x47); $result = ""; for($i=0, $j=0; $i<strlen($str); $i+=2) { $result .= chr(ord($str{$i} ^ 0) . chr(ord($str{$i+1}) ^ $XorKey[$j]); $j = ++$j % 8; } return $result;}
能顺便把加密函数也翻译一下吗
function Enc(Str:String):String;//字符加密函? ?是用的一??或加密
var
i,j:Integer;
begin
Result:='';
j:=0;
for i:=1 to Length(Str) do
begin
Result:=Result+IntToHex(Byte(Str[i]) xor XorKey[j],2);
j:=(j+1) mod 8;
end;
end;
好测试密文
给个密文,我测试看看~
给个密文,我测试看看~
<?php$XorKey = array(0xB2,0x09,0xAA,0x55,0x93,0x6D,0x84,0x47);function Dec($str){ global $XorKey; $result = ""; $j = 0; for ($i = 0; $i < strlen($str)/2; $i++) { $result = $result . chr(hexdec($str[$i*2] . $str[$i*2+1]) ^ $XorKey[$j]); $j = ++$j % 8; } return $result;}echo Dec("F76DC321A1");
$XorKey = array(0xB2,0x09,0xAA,0x55,0x93,0x6D,0x84,0x47);echo $s = enc('Edit2', $XorKey), PHP_EOL;echo dec($s, $XorKey);function Enc($Str, $XorKey) { //:String;//字符加密函? ?是用的一??或加密 $Result = ''; $j = 0; for($i=0; $i<strlen($Str); $i++) { $Result .= sprintf('%02X', ord($Str{$i}) ^ $XorKey[$j]); $j = ($j+1) % 8; } return $Result;}function Dec($str, $XorKey){ $result = ""; for($i=0, $j=0; $i<strlen($str); $i+=2) { $result .= chr(hexdec($str{$i} . $str{$i+1}) ^ $XorKey[$j]); $j = ++$j % 8; } return $result;}
能顺便把加密函数也翻译一下吗
function Enc(Str:String):String;//字符加密函? ?是用的一??或加密
var
i,j:Integer;
begin
Result:='';
j:=0;
for i:=1 to Length(Str) do
begin
Result:=Result+IntToHex(Byte(Str[i]) xor XorKey[j],2);
j:=(j+1) mod 8;
end;
end;
好测试密文
<?php$XorKey = array(0xB2,0x09,0xAA,0x55,0x93,0x6D,0x84,0x47);function Dec($str){ global $XorKey; $result = ""; $j = 0; for ($i = 0; $i < strlen($str)/2; $i++) { $result = $result . chr(hexdec($str[$i*2] . $str[$i*2+1]) ^ $XorKey[$j]); $j = ++$j % 8; } return $result;}function Enc($str){ global $XorKey; $result = ""; $j = 0; for ($i = 0; $i < strlen($str); $i++) { $result = $result. dechex(ord($str[$i])^$XorKey[$j]); $j = ++$j % 8; } return $result;}echo Enc("Edit2")."\n";echo Dec("F76DC321A1");
to: xuzuning 版主,你那个代码我执行的一直出错,不知道为什么。