D:\Work\CRC_HASH>D:\FPC304\bin\i386-win32\fpc.exe -b THMACSHA.PASFree Pascal Compiler version 3.0.4 [2017/10/06] for i386Copyright (c) 1993-2017 by Florian Klaempfl and othersTarget OS: Win32 for i386Compiling THMACSHA.PASLinking THMACSHA.exe14 lines compiled, 0.1 sec, 30848 bytes code, 1764 bytes dataD:\Work\CRC_HASH>THMACSHA.exe507285548137b5424eb5572c46496631b7ade8e88ac323c529fa142def26ffa1
If you want to calculate hmac, you can use HashLib4Pascalhttps://github.com/Xor-el/HashLib4Pascal
I used it and workedCode: Pascal [Select][+][-]function getsha256signature(StringToSign , mykey:string):string;var LHMAC: IHMAC;beginLHMAC := THashFactory.THMAC.CreateHMAC(THashFactory.TCrypto.CreateSHA2_256);LHMAC.Key := TConverters.ConvertStringToBytes(MyKey, TEncoding.UTF8);getsha256signature := LHMAC.ComputeString(StringToSign, TEncoding.UTF8).ToString();end; but my app start crashing, probably due to this previous function i had:Code: Pascal [Select][+][-]function GetTimestamp():string;BeginGetTimestamp := inttostr(Trunc((Now - EncodeDate(1970, 1 ,1)) * 24 * 60 * 60));end; ANy idea if this can be done with dcpcrypt?Quote from: Xor-el on June 01, 2018, 08:59:57 pmIf you want to calculate hmac, you can use HashLib4Pascalhttps://github.com/Xor-el/HashLib4Pascal@Gammatester i will try your code. Thanks!!
Code: Pascal [Select][+][-]don't know why your code is crashing but HashLib4Pascal is obviously not the cause.can you upload your code so we can check the cause of the crash?I think HashLib4Pascal is obviously the cause; i removed it from my project and i had no more troubles since then. IF your are the library developer, check why it crashes with my custom timestamp function (if i remove GetTimestamp function, then getsha256signature works and the app do not crash)Anyway, im cleaning my code to see if something else could be wrong.
I could send you the entire project by private. So you coudl check if it is something with your library.
It'd be nice to know how this turned out.
Yes, it was a lack of error handlers in my code. I implemented all the necessary handlers and i had no more errors. Thanks Xor-el for your time