S
S
Sergey2015-07-15 21:38:39
Delphi
Sergey, 2015-07-15 21:38:39

How to encrypt a request to the Instagram API with the SHA256 algorithm in Delphi?

Good afternoon everyone!
Understanding the Instagram API. There, the hash of the request itself, calculated using the secret key, must be added to the requests. There are examples for python, ruby ​​and PHP. They all use libraries or built-in functions.
I need to write a function or find a library for Delphi, but so far nothing. I really hope for general help.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey, 2015-07-16
@sezavasasilov

Thank you all for the witty replies! I found! Now I'm sharing with the world - suddenly someone will come in handy?

uses Hash, HMAC, HMACSHA2, Mem_Util
{...}
function HMAC_SHA256(AKey, AStr: AnsiString): String;
var
  ctx: THMAC_Context;
  mac: TSHA256Digest;
begin
  hmac_SHA256_init(ctx, @AKey[1], Length(AKey));
  hmac_SHA256_update(ctx, @AStr[1], Length(AStr));
  hmac_SHA256_final(ctx, mac);
  Result:=HexStr(@mac, SizeOf(TSHA256Digest));
end;

All necessary modules can be taken from here .

D
D', 2015-07-15
@Denormalization

>Enikeyshik
Enikeyshchik don't know how to google?

V
Vladimir Martyanov, 2015-07-15
@vilgeforce

No, because SHA is not encryption.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question