//****** 注册名 -> 注册码 换算函数 ******
//RegName为读入的注册名; RegCode为读入的注册码
function KeyGen(RegName: string): string;
var
cz : integer;
// textP, textCZ:string; //textCZ,textP,posP 都
// i, posP:integer; //为解密字符串所以变量
begin
cz := ord(RegName[1])*ord(RegName[7])+
ord(RegName[2])*ord(RegName[6])+
ord(RegName[3])*ord(RegName[5]);
cz := cz*cz xor ord(RegName[4]);
if length(intTostr(cz))>6
then Result := copy(intTostr(cz),1,7)
else begin
repeat
cz := cz*cz;
until length(intTostr(cz))>6;
Result := copy(intTostr(cz),1,7);
end;
//showmessage(Result);
{
//将 "\|]^K~_`?a??M???f?h?i??P???n??R???s??T" 解密
//为 "AaBC0cDdEe1FfGgH2hIiJj3KkLMm4NnOoP5pQqRr6SsTtU7uVvWw8XxYyZ9z"
textP := '\|]^K~_`?a??M???f?h?i??P???n??R???s??T';
for posP := 1 to length(textP) do
textP[posP] := chr(ord(textP[posP]) - 27); //'27'为解密的钥匙,重要
for i:=1 to Length(RegName) do //RegName为读取的注册名
Result:=Result + textP[( ( Ord(RegName[i]) + 7904 ) mod 27 ) + 1];
}
end;
procedure TForm1.BitBtnRegClick(Sender: TObject);
label
cz1,cz2,cz3;
begin
if (length(EditName.Text) > 6) //注册名长度大于6 (必须为7位数)
then begin
RegName := EditName.Text;//注册名
if (EditCode.Text <> '') //注册码不为空的话(必然为9位数)
then begin
RegCode := EditCode.Text;//注册码
if (ComboBox.Text <> '')
then begin //数值为: 7-2=5 //因为注册名长度小于8(为7位数)
if (length(EditName.Text)-ComboBox.ItemIndex)<6
then begin
if (Pos('79',EditCode.Text)>0)//尾数包含有'注册名+注册码'长度的字符
then begin
if (KeyGen(RegName)+
intTostr(length(EditName.Text))+
intTostr(length(EditCode.Text)))
<> RegCode
then goto cz1 //注册失败
else begin //数值为:7-2=5 //因为注册名长度小于8(为7位数)
if (length(EditName.Text)-ComboBox.ItemIndex)>4
then goto cz2 //注册成功
else goto cz1;//注册失败
end;
end
else goto cz1; //注册失败
end
else begin
cz1:
messageDlg(' Wrong Code!' +#13+#13+ 'Try It Again!',mtError,[mbOK],0);
exit;
cz2: //注册名长度小于8 (必须为7位数)
if (length(EditName.Text) < 8) and (ComboBox.ItemIndex = 2)
then messageDlg('!Good Job! ' + 'Registered To: '+RegName +' !Good Job!' +#13+#13+
'You really should congratulate yourself on this job!',
mtInformation,[mbOK],0)
else goto cz1;
exit;
cz3:
exit;
end;
end
else begin
ShowMessage('Select Your Key');
goto cz3;
end;
end
else begin
EditCode.Text := InputBox('Need Your Code!','Please Input Your Code Here:','');
//showmessage('input ur code');
goto cz3;
end;
end
else begin
EditName.Text := InputBox('Your Name Is Too Short!','Need More Than 6 Character:','');
//showmessage('input ur name');
goto cz3;
end;
end;