[SOLVED] REST API Consuming Help needed lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Blestan · 2017-11-04 19:56 HI guys im writing a lib to access Kraken.com tradind lib but i have problems with sha256 and sha512 functions to generate signing for the private functions ... can.you point me a good and consistent across languages hash lib? i tried. hash4pascal but cannot make it to work ... i need sha256 w/o key .. thanks in advance ---------------------------------------------------------------------- Leledumbo · 2017-11-05 03:54 You have several options: https://github.com/fundamentalslib/fundamentals5http://wiki.lazarus.fr eepascal.org/DCPcrypthttp://www.wolfgang- ehrhardt.de/crchash_en.htmlhttps://github.com/Xor-el/HashLib4Pascal ---------------------------------------------------------------------- Blestan · 2017-11-05 12:15 according to the api docs the requests must be signned as follow API-Key = API key API-Sign = Message signature using HMAC-SHA512 of (URI path + SHA256(nonce + POST data)) and base64 decoded secret API key here is my code but i still get error EAPI Invalid Key Code: [Select]function TKrakenAPI.QueryPrivate(const URI: string; Params: String): XVar; var S: TMemoryStream;     J: TJSONParser;     URL,     Sign,     Sha256,     Nonce: String;     R,I,L: Integer;     LHMAC: IHMAC;     sha512: PChar;     buf: array [00..64] of char; begin   Nonce:=IntToStr(DateTimeToUnix(Now));   Params:='nonce='+nonce+'&'+params;   sha256:=Nonce+Params;   URL:=kraken_private+URI;   L:=Length(URL);   Getmem(sha512,L+32);   Move(URL[1],Sha512^,L);   with THashFactory.TCrypto.CreateSHA2_256().ComputeUntyped(sha256[1], Length(Sha256)) do        move(getbytes[0],sha512[L],32);   LHMAC:= THashFactory.THMAC.CreateHMAC(THashFactory.TCrypto.CreateSHA2_512);   LHMAC.Key := TConverters.ConvertStringToBytes(DecodeStringBase64(FSecret), TEncoding.UTF8);   // sign:=EncodeStringBase64(LHMAC.ComputeUntyped(sha512,L+32).ToString);   move(LHMAC.ComputeUntyped(sha512,L+32).GetBytes[0],Buf[0],64);   Buf[64]:=#0;   sign:=EncodeStringBase64(Pchar(@Buf[0]));   try   FNET.AddHeader('API-Key:',FKEY);   FNET.AddHeader('API-Sign:',Sign);   FNET.AddHeader('Content-Type', 'application/x-www-form-urlencoded');   FNET.AddHeader('Content-Length', IntToStr(Length(Params)));    writeln(Nonce);    writeln(URL);    writeln(sha512);    writeln(sign);    S:=TMemoryStream.Create;    J:=TJSONParser.Create;    FNet.FormPOST(KrakenURL+URL,Params,S);    R:=J.Parse(S.Memory,S.Size);    writeln(R);    if R>0 then Result:=J.UseXON           else Result:=XVar.Null;    with Result['result'] do     for i:=0 to Count-1 do writeln(Keys[i].AsString,'=',Vars[i].AsString);   finally     J.Free;     S.Free;   end; end; ---------------------------------------------------------------------- Blestan · 2017-11-05 14:58 problem solved! ) if someone is interested in kraken.com API access from fpc feel free to contact me ---------------------------------------------------------------------- william22 · 2018-10-08 09:57 Dear Blestan, Could you please share your code? I'm having throuble posting the private functions.