更新时间:2022-05-24 22:36:28
使用 Password
指令.
Use CheckPassword
event function instead of Password
directive.
[Code]
{ Passwords cache in case their retrieval is time consuming }
var
Passwords: array of string;
function CheckPassword(Password: String): Boolean;
var
Index: Integer;
SHA1: string;
begin
{ CheckPassword may be called before any other code (including InitializeSetup), }
{ so any initialization has to happen in the function itself. }
if GetArrayLength(Passwords) = 0 then
begin
Log('Initializing hashes');
SetArrayLength(Passwords, 5);
Passwords[0] := 'df65784979efcda967c88de7098a5a106101064e';
Passwords[1] := 'b78baf5db4b1498ed075b8e6accd0b5ff51e20ec';
Passwords[2] := 'aaf70585b9a2662c911392b7573c739cecea0e56';
Passwords[3] := '3ab4222e2d0000012e6c7381437178fab398e8aa';
Passwords[4] := '5473ccc879a8167a6a77b387a916f7c9ca05894f';
end;
Index := 0;
SHA1 := GetSHA1OfUnicodeString(Password);
for Index := 0 to GetArrayLength(Passwords) - 1 do
begin
if SHA1 = Passwords[Index] then
begin
Log(Format('Password matches hash %d', [Index]));
Result := True;
Exit;
end;
end;
Log(Format('Password matches nothing our of %d hashes', [GetArrayLength(Passwords)]));
Result := False;
end;