How to generate base64 digest string in Appian.

Certified Senior Developer

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

Parents
  • 0
    Certified Lead Developer

    Can you clarify on what you mean exactly by "base64 digest string"?  What is your input and what is your desired output?  If, for example, it just requires translation of a string to Base64, this can be done OOtB.

  • 0
    Certified Senior Developer
    in reply to Mike Schmitt

    Hello Mike,

    Thank You for the response.

    I need to get the equivalent hash value of the given string. First, need to get the SHA256 hash of the given string and convert the value to base64.

    I've done using Java code and exposed it as an Appian function.

  • 0
    Certified Lead Developer
    in reply to Sneha Yada

    That sounds good.  I've previously written an OOB Appian expression to convert text to Base64, but I don't have any solution for the SHA256 hash portion so i'm glad you figured something out.  Did you develop this as a plug-in or use some other method to expose it to Appian, if I may ask?

  • 0
    Certified Senior Developer
    in reply to Mike Schmitt

    Hello Mike,

    Yes, I developed it as an Appian plug-in.

    May I know the Appian OOB expression which converts text to Base64?

  • +1
    Certified Lead Developer
    in reply to Sneha Yada

    I just wrote one myself a year or so ago.  Let me see if I can find where I saved the rule code...
    edit: here you go--

    /* encode */
    a!localVariables(
      /*local!text: "Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.",*/
      local!text: ri!text,
    
      local!charset: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
      local!codeArray: code(local!text),
      local!bins: concat(dec2bin(local!codeArray, 8)),
      local!groupedBins: split(concat(
        a!forEach(
          code(local!bins), 
          char(fv!item) & if(and(mod(fv!index, 6) = 0, not(fv!isLast)), "-=-=-", "")
        )
      ), "-=-=-" ),
      local!lastBin: index(local!groupedBins, length(local!groupedBins)),
      local!padding: if(
        len(local!lastbin) = 2,
        "==",
        len(local!lastbin) = 4,
        "=",
        len(local!lastbin) = 6,
        "",
        "error condition"
      ),
      local!bindexes: a!forEach(
        local!groupedBins,
        if(
          fv!isLast,
          bin2dec(substitute(padright(fv!item, 6), " ", "0")),
          bin2dec(fv!item)
        )
      ) + 1,
    
      local!assembledOutput: concat(a!forEach(local!bindexes, charat(local!charset, fv!item))) & local!padding,
    
      local!assembledOutput
    )

  • Hi! is it public that plug in? im facing the same issue in Appian, to call a soap WS. The WS requires a Digested password, with encode64(sha1(nonce, created, password)); and we cant make the request from Apian, (authentication failure).

    Thanks in advance!

  • 0
    Certified Senior Developer
    in reply to facundoc1624

    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

Reply Children
No Data