Hello All,
Below is the code snippet from Ruby.
Digest::SHA256.base64digest('')
I need to generate the same in Appian and pass it to the integration header parameter, please let me know if anyone has done this before.
Thank You,
Sneha.
Discussion posts and replies are publicly visible
Hello, it's not a public plugin, I've created it as a function and called it from Appian
and the functions which I developed will perform the below tasks
1. SHA256 digest of the request body in Base64 string
2. Encode a string using HMAC and SHA256 digest
Hi Mike,This code snippet, will help us to convert simple text to base64 ?
Neha Dangi said:This code snippet, will help us to convert simple text to base64 ?
Yes, the code I posted (which is custom code I wrote 100% from scratch on my own in Appian) should generate standard Base64 given an input string. I've tested the base64 it generates with external base64 convertors and at least thus far I haven't found any areas where it doesn't work correctly.
Mike, do you happen to have a base64 decoder written as well? I'll try to reverse engineer your encoder in the meantime. Thanks!
Jason said:do you happen to have a base64 decoder written as well?
In fact, yes.
/* decode */ a!localVariables( local!base64text: ri!base64text, local!charset: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", local!charCodes: code(local!base64text), /*local!paddingCount: count(wherecontains(code("="), local!charCodes)),*/ local!unpaddedChars: a!flatten(a!forEach( items: local!charCodes, expression: if(fv!item = code("="), {}, find(char(fv!item), local!charset)-1) )), local!rawBins: dec2bin(tointeger(local!unpaddedChars), 6), local!decodedBins: split( concat( a!forEach( items: code(concat(local!rawBins)), expression: if( mod(fv!index, 8) = 0, char(fv!item) & "-=-=-", char(fv!item) ) ) ), "-=-=-" ), concat( a!forEach( items: local!decodedBins, expression: if( or(fv!item = "0000", fv!item = "00"), null(), char(bin2dec(fv!item)) ) ) ) )
You sir, are my hero!
Great work!!!
Have you tested the limits of characters for this code?
Alexis Díaz Fajardo said:limits of characters
Within reason. Do you have anything specific in mind?
To confirm - i just tested it on a 10,000 character randomly-generated Lorem Ipsum text, and it worked in less than 5 seconds. I guess I'd hesitate to call it on text much longer than this, just for performance concerns.
Thats nice to hear. Im asking because the plugin Base64 Expressions have in its functions a character limit of 150.