#1 Re: mORMot 2 » Different behaviour of HmacSha1 between Delphi and Postman CryptoJS » 2025-02-07 07:46:16

Didn't notice the URI, you're right.

The following code works fine:

procedure TForm1.btnGeneraCodiceClick(Sender: TObject);
const
  SECRET_KEY: RawByteString = 'myPrivateKey12345!!';
var
  sData,
  sSignature64: RawByteString;

  SHAOutput: TSHA1Digest;
begin
  sData := 'POS-1|2025-01-25|43';
  HmacSha1(SECRET_KEY, sData, SHAOutput);
  sSignature64 := BinToBase64(@SHAOutput, 20);
end;

Thanks

#2 mORMot 2 » Different behaviour of HmacSha1 between Delphi and Postman CryptoJS » 2025-02-06 11:36:55

g_garzotto
Replies: 2

Hello,

I'm using Delphi 7 and mORMot2.

This code:

procedure TForm1.btnGeneraCodiceClick(Sender: TObject);
const
  SECRET_KEY: RawByteString = 'myPrivateKey12345!!';
var
  sData,
  sSignature64: RawByteString;

  SHAOutput: TSHA1Digest;
begin
  sData := 'POS-1|2025-01-25|43';
  HmacSha1(SECRET_KEY, sData, SHAOutput);
  sSignature64 := BinToBase64URI(@SHAOutput, 20);
end;

returns in variable sSignature64 the value

AwxPbTUf5OGaFaxmmV6HwgpA0wU

which have a lenght of 27 chars.

The following code executed in Postman:

var CryptoJS = require('crypto-js');

var secretKey = "myPrivateKey12345!!";
var dataString = "POS-1|2025-01-25|43";

var signatureBytes = CryptoJS.HmacSHA1(dataString, secretKey);
var signatureBase64 = CryptoJS.enc.Base64.stringify(signatureBytes);
console.log("signatureBase64: ", signatureBase64);

returns in variable signatureBase64 the value

AwxPbTUf5OGaFaxmmV6HwgpA0wU=

which have a lenght of 28 chars.

I can't figure out if I wrong something in my code, or if there are some issues in the code.

I found the same behaviour also in mORMot 1.

Can you point me in some directions to solve my problem ?

Thanks in advice, regards

Giuseppe Garzotto

#3 Re: mORMot 1 » Read entire body of a POST call from server » 2023-09-07 15:37:47

Yes, one minute after submit I found what I need in another post.

Ctxt.Call.InBody solve all my needs.

Thanks

#4 mORMot 1 » Read entire body of a POST call from server » 2023-09-07 15:20:18

g_garzotto
Replies: 2

I have defined a method based service.

I need to perform a POST call from a client (initially Postman, in production will be an Angular application).

I would  like to read entire body of the call, that will contain a complex JSON that I need to parse.

How can do it ?

Thanks in advice

Board footer

Powered by FluxBB