I am working on consuming some REST APIs and am having trouble getting the hashing algorithm to work properly when Line Feeds are involved.
The hashing uses SHA-256 HMAC with the output encoding as Base64. This is the string in the sample provided by the REST API documentation.
The key from their sample is also using Base64 encoding.host: apitest.cybersource.com
date: Fri, 21 Mar 2025 04:32:08 GMT
request-target: post /pts/v2/payments/
digest: SHA-256=ZWTHRbrcpmA5sUP4W5BjzdwIcMzVxcBGIPtL5KdoWNE=
v-c-merchant-id: testrest
I used the website https://emn178.github.io/online-tools/sha256.html to test this and it matches with what is in the API documentation's results. The hashed value provided by the website and the sample in the API docs is below:yBJxy6LjM2TmcPGu+GaJrHtkke25fPpUX+UY6/L/1tE=
When I try this in Lansa, I keep getting different hashed values which I suspect is due to my mishandling of the Line Feeds. I then tried to test this theory by removing the LineFeeds.JFiQe35A6Sc7Vfu6YhhVi6IxefCQnz6AQHw1f4MsyYQ=
And I got this result from my Lansa Form, which also matches with results in https://emn178.github.io/online-tools/sha256.html for the same String.host: apitest.cybersource.com date: Fri, 21 Mar 2025 04:32:08 GMT request-target: post /pts/v2/payments/ digest: SHA-256=ZWTHRbrcpmA5sUP4W5BjzdwIcMzVxcBGIPtL5KdoWNE= v-c-merchant-id: testrest
Does anyone know how to configure Strings in Lansa to behave similarly with LineFeeds? I have tried the following and nothing has worked so far:7kLPdWxkZvkQWDlLBf8QyiWEcIuK2dGRGHf6XAuzrX4=
- Used (10).asUnicodeString at the end of each line (except the last line)
- Appended "\n" at the end of each line (except the last line)
- Used field types String and NVarChar