Support Article
Base64 Encoding not working correctly
SA-52647
Summary
Encoded string returning a white space when function @Base64Encode used.
Error Messages
Not Applicable
Steps to Reproduce
Call function @Base64Encode("74d8814c921945a9b87aa12805a233ba:d652c746718e4fbc04a6e382d41c6de492ad938cf4026af41635b7976cee94a2")
Encoded String: NzRkODgxNGM5MjE5NDVhOWI4N2FhMTI4MDVhMjMzYmE6ZDY1MmM3NDY3MThlNGZiYzA0YTZlMzgy ZDQxYzZkZTQ5MmFkOTM4Y2Y0MDI2YWY0MTYzNWI3OTc2Y2VlOTRhMg==
White space introduced in between the encode string.
Root Cause
The function calls engine layer Bas64Util.encode(inputStr);
At the engine layer this is ends up calling encode(inputStr, true) , the second parameter is a boolean that triggers adding the line breaks.
This is working as designed and conforms to Base64 transfer encoding for MIME (RFC 2045) which is used for base64 encoding binary data.
The primary use of this function in PRPC is the encoding of binary attachment data.
Resolution
Perform the following local-change steps:
1. Use a Java step or @java() in a property set step to directly call the Bas64Util.encode(inputStr, false) if it is not require the output to contain a line break every 76 characters.
2. Add enhancement request asking for secondary function @Base64EncodeNoLB that will call Base64Util.encode(inputStr, false).
Published May 23, 2018 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.