SHA-1(1120EAC24C0EC0926DFBD6EB27377CF7)
=0xC1EB756FB06BA7DB7D17E19A3E35F9B51A2F9897
pick first 4 bytes=C1EB
Base32(1120EAC24C0EC0926DFBD6EB27377CF7+C1EB)
="CESQXSUNB5AKE5R545XUQP5689A8Y"
-------------------------------------------------------------------------------------
pick 2st of the result=E(45h) div 0x1D=2<B> -->0x0B
pick 0Bst of the result=K(4Bh) div 0x0F=5<0> 0+0=0
pick 0st of 'BCDEFGHJKLMNPQRSTUVWXY123456789'='B'
var
Form1: TForm1;
chr32 : Array[1..32] Of char = ('A','B','C','D','E','F','G','H','J','K','L',
'M','N','P','Q','R','S','T','U','V','W','X',
'Y','1','2','3','4','5','6','7','8','9');
implementation
uses FGInt, FGIntRSA;
{$R *.dfm}
function PreprocessUserData(var S:string) :string ;
begin
Result:=S;
Result:=AnsiReplaceStr(Result,' ','');
Result:=AnsiReplaceStr(Result,'.','');
Result:=AnsiReplaceStr(Result,',','');
Result:=AnsiReplaceStr(Result,';','');
Result:=AnsiReplaceStr(Result,'+','');
Result:=AnsiReplaceStr(Result,'-','');
Result:=AnsiReplaceStr(Result,'&','');
Result:=AnsiReplaceStr(Result,#223,'ss');
Result:=AnsiReplaceStr(Result,#228,'ae');
Result:=AnsiReplaceStr(Result,#246,'oe');
Result:=AnsiReplaceStr(Result,#252,'ue');
Result:=AnsiReplaceStr(Result,#200,'Ae');
Result:=AnsiReplaceStr(Result,#214,'Oe');
Result:=AnsiReplaceStr(Result,#220,'Ue');
end ;
function HashUserData(const S:string):string ;
var
HashManager1:THashManager;
strTemp:String;
begin
HashManager1:=THashManager.Create(nil);
HashManager1.Algorithm:='Message Digest 5';
HashManager1.CalcString(S);
strTemp:=HashManager1.Digest;
HashManager1.Destroy;
Result:=copy(strTemp,1,9);
end;
function CalcShortHash(const S:string):string;
var
HashManager2:THashManager;
strTemp:String;
begin
HashManager2:=THashManager.Create(nil);
HashManager2.Algorithm:='SHA1';
HashManager2.CalcString(S);
strTemp:=HashManager2.Digest;
HashManager2.Destroy;
Result:=copy(strTemp,1,2);
end;
Procedure Base32to256(str32 : String; Var str256 : String);
Var
i, len8 : longint;
g : char;
str2:String;
Begin
ConvertBase32To2(str32,str2);
Strlcopy(PAnsiChar(str2),PAnsiChar(str2),(strlen(PAnsiChar(str2))-1));
str256 := '';
//While (length(str2) Mod 8) <> 0 Do str2 := '0' + str2;
len8 := length(str2) Div 8;
For i := 1 To len8 Do
Begin
zeronetochar8(g, copy(str2, 1, 8));
str256 := str256 + g;
delete(str2, 1, 8);
End;
End;
Procedure Base256to32(str256 : String; Var str32 : String);
Var
i, len5{,iMod }: longint;
g : integer;
str2:string;
temp:char;
Begin
ConvertBase256To2(str256,str2);
str32 := '';
str2:=str2+'0';
{iMod:=length(str2) mod 5;
For i:=0 To iMod Do
Begin
str2:=str2+'0';
End; }
len5 := length(str2) Div 5;
For i := 1 To len5 Do
Begin
zeronetochar5(g, copy(str2, 1, 5));
temp:=chr32[g];
{if temp='V' then temp:='U';
if temp='1' then temp:='L';
if temp='2' then temp:='Y';
if temp='3' then temp:='E';
if temp='4' then temp:='A';
if temp='5' then temp:='S';
if temp='6' then temp:='G';
if temp='7' then temp:='J';
if temp='8' then temp:='B';
if temp='9' then temp:='F';}
str32 := str32 + temp;
delete(str2, 1, 5);
End;
End;
procedure TForm1.Button1Click(Sender: TObject);
var
HugeIntP,HugeIntQ,HugeIntN,HugeIntPhi,HugeIntE,HugeIntD,HugeInt_NULL:TFGInt;
str_Orig,str_Temp1,str_Temp2,str_Temp3,str_Hash,string_E,string_Name,string_Company,string_SN,string_User:string;
str_32,str_256,str_2:string;
i,j,k,iMod:Integer;
bool_find:boolean;
chr_Temp:Char;
str_Re1,str_Re2:String;
Reg: TRegistry;
begin
Base10StringToFGInt('72378278544376610161864186209559902527',HugeIntN);
Base10StringToFGInt('55224941890616846913011184334819912063',HugeIntD);
Base10StringToFGInt('8691021235324000873',HugeIntP);
Base10StringToFGInt('8327937141633085799',HugeIntQ);
HugeIntP.Number[1]:=HugeIntP.Number[1]-1;
HugeIntQ.Number[1]:=HugeIntQ.Number[1]-1;
FGIntMul(HugeIntP,HugeIntQ,HugeIntPhi);
FGIntModInv(HugeIntD,HugeIntPhi,HugeIntE);
FGIntToBase10String(HugeIntE,string_E);
//Edit1.Text:=string_E;
string_Name:=Edit1.Text;
string_Name:=Trim(string_Name);
string_Name:=LowerCase(string_Name);
string_Company:=Edit2.Text;
string_Company:=Trim(string_Company);
string_Company:=LowerCase(string_Company);
string_User:=string_Name+'|'+string_Company;
string_User:=PreprocessUserData(string_User);
string_User:=string_User+'+'+'TU2006';
str_Hash:=HashUserData(string_User);
str_Orig:=#00#00#6#1#00+str_Hash;
For j:=0 To 255 Do
Begin
For k:=0 To 255 Do
Begin
For i:=0 To 31 Do
Begin
RSAEncrypt(str_Orig,HugeIntE,HugeIntN,str_Temp1);
if strlen(PAnsiChar(str_Temp1))<>15 then
begin
str_Temp1:='';
Inc(str_Orig[5]);
end
else
begin
bool_find:=True;
Break;
end
End;
If bool_find=True then
Break
else
Inc(str_Orig[2]);
End;
If bool_find=True then
Break
else
Inc(str_Orig[1]);
End;
str_Orig:=str_Temp1+CalcShortHash(str_Temp1+#32#36#65);
Base256To32(str_Orig,str_32);
chr_Temp:=str_32[12];
iMod:=Ord(chr_Temp) mod 29;
chr_Temp:=str_32[iMod+1];
iMod:=Ord(chr_Temp) mod 15;
iMod:=iMod+iMod+1;
chr_Temp:=chr32[iMod];
Randomize;
iMod:=RandomRange(1,32);
str_32:=str_32+chr32[iMod];
iMod:=RandomRange(1,32);
str_32:=str_32+chr32[iMod]+chr_Temp;
Insert('-',str_32,6);
Insert('-',str_32,12);
Insert('-',str_32,18);
Insert('-',str_32,24);
Insert('-',str_32,30);
Edit3.Text:=str_32;
Reg:=TRegistry.Create;
try
Reg.RootKey:=HKEY_CURRENT_USER;
Reg.OpenKey('Software\TuneUp\Utilities\5.0',true);
Reg.WriteString('RegCode',str_32);
str_Re1:=Reg.ReadString('RegCode');
finally
Reg.Free;
Edit4.Text:= str_Re1;
end;
end;