cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Base64 to byte array conversion in CPI

0 Likes
2,316

Hello Experts,

We have a requirement to convert base64 value of a field and convert it into byte array format and pass it to target system. Could this be achieved through CPI interface ?

Regards,

Varun Vichare.

View Entire Topic
Sriprasadsbhat
Active Contributor
0 Likes

Hello Varun,

Yes this is possible and below is the snippet of groovy that does the same.

def s = 'Argh, Groovy you say, mate?'
 
String encoded = s.bytes.encodeBase64().toString()
assert 'QXJnaCwgR3Jvb3Z5IHlvdSBzYXksIG1hdGU/' == encoded
 
byte[] decoded = encoded.decodeBase64()
assert s == new String(decoded)

Regards,

Sriprasad Shivaram Bhat