How to perform base64 encoding or decoding using PeopleCode?

Define two new algorithm chains under PeopleTools > Security > Encryption > Algorithm Chain:

Algorithm BASE64_ENCODE:
1 PSUnicodeToAscii
2 base64_encode
3 PSAsciiToUnicode

Algorithm BASE64_DECODE:
1 PSUnicodeToAscii
2 base64_decode
3 PSAsciiToUnicode

Note the sequence as they are very important and must be exactly as ordered.
Define Encryption Profiles using the chains above under PeopleTools > Security > Encryption Profile. As an example here, profile names BASE64_ENCODE and BASE64_DECODE will be used for the sample code below.
After the encryption profiles are set up, they can be called upon by the PeopleCode Crypt class.

Example Code:
Local Crypt &cryEncode, &cryDecode;
Local string &encodeResult, &decodeResult;

/* ENCODE */
&cryEncode = CreateObject("Crypt");
&cryEncode.Open("BASE64_ENCODE");
&cryEncode.UpdateData("This is the text to be encoded");
&encodeResult = &cryEncode.Result;

/* DECODE */
&cryDecode = CreateObject("Crypt");
&cryDecode.Open("BASE64_DECODE");
&cryDecode.UpdateData(&encodeResult);
&decodeResult = &cryDecode.Result;

Comments

Popular posts from this blog

Peoplesoft SFTP

How to find the Java Version being used by WebLogic

Peoplesoft Error: All Processing Suspended: Restart OPRID=PS, RUNID=RUN01, PI=5000(108,503)