why do these base64 encoding methods returning different – groovy and javascript


i am trying to encode a string on base64 algorithm. i want to get output as just like javascript below, but in Groovy. when i use below script, i am getting different output encodes. can anyone help me understand and get the correct one for groovy?

Javascript:

var test = CryptoJS.enc.Base64.parse("Hello World!");
console.log("test = " + test);

output: test = 1de965a005a8ae5740

Groovy script:

String decoded = "Hello World!"
byte[] dcB = decoded.getBytes("UTF-8")
String encoded = dcB.encodeBase64()
log.info encoded

Output: SGVsbG8gV29ybGQh

Source: JavaSript – Stack Overflow

November 19, 2021
Category : News
Tags: base64 | encoding | groovy | javascript

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.