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 Reply
  • 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))
          )
        )
      )
    )

Children