Closed dw0111 closed 3 years ago
Hi, you are doing the last part wrong. Replace mRes := TConverters.ConvertBytesToString(LGenerator.GetBytes(66), TEncoding.Unicode); with mRes := TConverters.ConvertBytesToHexString(LGenerator.GetBytes(66), false);
Hi, thank you for your reply and sorry that it took me so long to answer, it's been busy and I haven't had time yet to check your my code with your solution. Thank you anyway, I hope I'll get around to it in the near future.
Hi,
I tried to verify a Hash wich was made with the php_hash function. In the german language there are special characters. I used the encoding UTF8 and unicode, but the result is with asian characters.
The version I used was downloaded in September. The Delphi version is 10.4.2 with all patches applied.
procedure verify; var LGenerator: IPBKDF_Argon2;
mRes, LActual, FAdditional, FSecret, FSalt, FPassword: String;
LAdditional, LSecret, LSalt, LPassword: TBytes;
LArgon2Parameter: IArgon2Parameters;
Argon2ParametersBuilder: IArgon2ParametersBuilder;
begin (
php Result "Knüllerß#" : $argon2i$v=19$m=65536,t=4,p=1$T2hqaURkbUI2SVVkeTZqaw$eT3Cr9d/PRpLS9aQViuSt0NYSgUjMzFJvnR8aWEC6T8 )
FAdditional := ''; FSecret := ''; FSalt := 'T2hqaURkbUI2SVVkeTZqaw'; FPassword := 'Knüllerß#';
Argon2Version := TArgon2Version.a2vARGON2_VERSION_13; Argon2ParametersBuilder := TArgon2dParametersBuilder.Builder();
LAdditional := TConverters.ConvertStringToBytes(FAdditional,TEncoding.UTF8); LSecret := TConverters.ConvertStringToBytes(FSecret,TEncoding.UTF8); LSalt := TConverters.ConvertStringToBytes(FSalt,TEncoding.UTF8); LPassword := TConverters.ConvertStringToBytes(FPassword,TEncoding.UTF8);
Argon2ParametersBuilder .WithVersion(Argon2Version) .WithIterations(4) .WithMemoryAsKB(65536) .WithParallelism(1) .WithAdditional(LAdditional) .WithSecret(LSecret) .WithSalt(LSalt);
LArgon2Parameter := Argon2ParametersBuilder.Build(); Argon2ParametersBuilder.Clear();
LGenerator := TKDF.TPBKDF_Argon2.CreatePBKDF_Argon2(LPassword, LArgon2Parameter); mRes := TConverters.ConvertBytesToString(LGenerator.GetBytes(66), TEncoding.Unicode);
// mRes -> '밖씤섲䍺ﲿ'#$26CE'궛櫳ﺠ'#$0EA4'第墱'#$08BC'埐⺇'#$D978'찠쌿᧧颩ဢ⤔栅�梵鋕蜷'
LArgon2Parameter.Clear(); LGenerator.Clear(); end;