Hola,
llevo semanas tratando de hacer funcionar bien un código de delphi7 en embarcadero xe3.
pero da la casualidad, que en delphi7 me da un código PIC y en embarcadero me genera otro
Código Delphi
[-]function md5(const Input: String): String;
var
hCryptProvider: HCRYPTPROV;
hHash: HCRYPTHASH;
bHash: array[0..$7f] of Byte;
dwHashBytes: Cardinal;
pbContent: PByte;
i: Integer;
begin
dwHashBytes := 16;
pbContent := Pointer(PChar(Input));
Result := '';
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 TForm2.Button1Click(Sender: TObject);
var
aHash,S, aKey : String;
Tmp : array [1..16] of integer;
i:integer;
begin
aHash := Md5(Edit1.text);
for i:=1 to 16 do Tmp[i]:=StrToInt('$'+rightStr(leftstr(aHash,2*i),2));
aKey:='';
for i:=1 to 8 do aKey:= aKey + IntToStr((((Tmp[i]+Tmp[i+8])and$FF)*9)div$FF);
while(length(akey)<8) do aKey:='0'+aKey;
memo1.lines.Clear;
Memo1.Lines.Add('PIC:' + akey);
end;
end.
valor : 235641110256249
resultado
PIC:47553704 esto en XE3 pero en delphi7 da :
PIC:86536540
uso esto
Wcrypt2.rar
gracias por la ayuda