Search code examples
intersystems-cacheintersystems

Base64 encoding and decoding using Caché Object Script


Is there any "built-in" methods or ways to encode/decode to/from BASE64 string in Caché?


Solution

  • To encode: Write $System.Encryption.Base64Encode("text")

    To decode: Write $System.Encryption.Base64Decode("dGV4dA==")

    Note: Base 64 encoding is not able to encode a string which contains unicode (2 byte) characters. If you need to Base 64 encode an unicode string, you should first translate the string to UTF8 format, then encode it.