function TCommon.getPastureKey(serverTime: Integer): string;
var
SHA1Context: TSHA1Context;
SHA1Digest: TSHA1Digest;
password: string;
str: string;
p: array[0..39] of char;
begin
str := '8$#f3o!$Fa90fAl=SDF2';//'983o!$Fl*&#F?dsd!^12';
//'wfasdf*&#F?sd$@AFWaf'; //'97b2d!@0b8f1@&%#$xsf';
repeat
password := IntToStr(serverTime) + Copy(str, (serverTime mod 10) + 1, 100);
SHA1Init(SHA1Context);
SHA1Update(SHA1Context, PChar(password), Length(password));
SHA1Final(SHA1Context, SHA1Digest);
BinToHex(PChar(@SHA1Digest), p, strlen(PChar(@SHA1Digest)));
Result := Trim(p);
Dec(serverTime);
until Length(Result) = 40;
Result := LowerCase(Result);
end;
转载于:https://www.cnblogs.com/saakee/archive/2010/09/05/1818480.html