我在我的項目中使用crypto api WCrypt2 for md5 crypt但我不知道解碼。你能給我提供加密API的解碼功能嗎?delphi crypto api decode
在我的項目中,我需要從波紋管使用此加密代碼。 DECODE函數必須與label1和Edit1.Bouth工作包括在形式啓動,但對於解碼,我將使用Button1的
這裏是我的代碼:
unit HUID;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdGlobal, IdHash, IdHashMessageDigest, WCrypt2;
type
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Button1: TButton;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function GetEnvVarValue(const VarName: string): string;
var
BufSize: Integer; // buffer size required for value
begin
// Get required buffer size (inc. terminal #0)
BufSize := GetEnvironmentVariable(PChar(VarName), nil, 0);
if BufSize > 0 then
begin
// Read env var value into result string
SetLength(Result, BufSize - 1);
GetEnvironmentVariable(PChar(VarName),
PChar(Result), BufSize);
end
else
// No such environment variable
Result := '';
end;
function md5(const Input: string): string;
var
i: Integer;
pbContent: PByte;
dwHashBytes: Cardinal;
hHash: HCRYPTHASH;
hCryptProvider: HCRYPTPROV;
bHash: array[0..$7f] of Byte;
begin
Result := '';
dwHashBytes := 16;
pbContent := Pointer(PChar(Input));
if CryptAcquireContext(@hCryptProvider, nil, nil, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT or CRYPT_MACHINE_KEYSET) then
begin
if CryptCreateHash(hCryptProvider, CALG_MD5, 0, 0, @hHash) then
begin
if CryptHashData(hHash, pbContent, Length(Input) * sizeof(Char), 0) then
begin
if CryptGetHashParam(hHash, HP_HASHVAL, @bHash[0], @dwHashBytes, 0) then
begin
for i := 0 to dwHashBytes - 1 do
begin
Result := Result + Format('%.2x', [bHash[i]]);
end;
end;
end;
CryptDestroyHash(hHash);
end;
CryptReleaseContext(hCryptProvider, 0);
end;
Result := AnsiLowerCase(Result);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Label1.Caption := (GetEnvVarValue('PROCESSOR_REVISION')+GetEnvVarValue('PROCESSOR_LEVEL')+GetEnvVarValue('NUMBER_OF_PROCESSORS')+GetEnvVarValue('Cor_Debugging_Control_424242'));
Edit1.Text := md5(Label1.Caption);
end;
end.
MD5是一種單向散列算法,它不能被解碼,只能蠻力猜測 –
這是你需要退後一步並仔細看看你真正想要達到的目標。 –
如果Zathrus的評論不夠,請定義「解碼」。 –