这是十六进制值的解码函数, 我试图找出它的编码功能,但没有运气。
function dtwin(flg: Integer): Integer;
var i:integer;
ner,yrd, yrv :Cardinal;
unr :Int64;
begin
ner := 1;
unr := flg;
yrd := $2E8CFFB0;
yrv := $0C8CFFF0;
for i := 1 to 32 do
begin
if (yrv and 1) <> 0 then
begin
ner := ((ner * unr) mod (yrd));
end;
unr := ((unr * unr) mod (yrd));
yrv := (yrv shr 1) and $7FFFFFFF;
end;
Result := ner;
end;
答案 0 :(得分:4)
简短的回答是:无法完成。
请阅读:
http://en.wikipedia.org/wiki/Modular_exponentiation
设b = flg
设e = $ 0C8CFFF0 = 210567152
设m = $ 2E8CFFB0 = 780992432
然后这个函数正在计算(b ^ e)mod m
要反转它,我们需要找到e mod m的乘法逆。
我尝试过使用WolframAlpha。
http://www.wolframalpha.com/input/?i=multiplicative+inverse+of+210567152+mod+780992432
它给出的结果是:
(210567152不可逆模780992432)
原因是e和m不是共同素数。它们都可被2整除。
由此我们可以得出结论,没有办法扭转这个功能,因为存在分歧。 举个例子:
dtwin(60)= dtwin(2326)= 62188800
使用参数62188800调用时,反向函数应该返回什么? 应该返回60还是2326?
以下是一些碰撞的例子:
dtwin(658) = dtwin(1300) = 682595280
dtwin(60) = dtwin(2326) = 62188800
dtwin(1316) = dtwin(2600) = 76519712
dtwin(2312) = dtwin(3522) = 317601904
dtwin(1974) = dtwin(3900) = 52357088
dtwin(120) = dtwin(4652) = 144155936
dtwin(2632) = dtwin(5200) = 679101872
dtwin(3290) = dtwin(6500) = 322955216
dtwin(3989) = dtwin(6725) = 301338273
dtwin(180) = dtwin(6978) = 628048624
dtwin(4624) = dtwin(7044) = 435300992
dtwin(5080) = dtwin(7658) = 2152880
dtwin(3948) = dtwin(7800) = 682904608
dtwin(2685) = dtwin(8183) = 461799889
dtwin(2461) = dtwin(8951) = 170465
dtwin(4606) = dtwin(9100) = 138445536
dtwin(240) = dtwin(9304) = 231258592
dtwin(4741) = dtwin(9603) = 586985553
dtwin(6117) = dtwin(9923) = 277591073
要生成可能对加密有用的结果,您可以按如下方式生成数字。 我不会在这里详细介绍它是如何工作的。如果您需要了解更多信息,可以使用Google公钥加密技术。
Select P and Q that are prime.
Compute N = P * Q
Compute T = (P-1) * (Q-1) This is called the totient.
Select E that is coprime to N and T.
Select D that is the multiplicative inverse of E mod T.
你的模数是N.两个指数是E和D.
To encrypt A, calculate B = ( A ^ E ) mod N
To decrypt B, calculate A = ( B ^ D ) mod N
请注意,在实际加密中,这些值通常包含数百或数千个数字。
以下是您的示例中数量级的一些结果:
N = 590108483 =$232C5743
E = 547145911 =$209CC8B7
D = 507147559 =$1E3A7527
N = 763464677 =$2D818BE5
E = 545809367 =$208863D7
D = 622691303 =$251D83E7
N = 948703211 =$388C0FEB
E = 885205759 =$34C32AFF
D = 893844127 =$3546FA9F
N = 897918037 =$35852455
E = 894567871 =$355205BF
D = 539129719 =$20227777
N = 754905647 =$2CFEF22F
E = 540902531 =$203D8483
D = 534729131 =$1FDF51AB