Base64 Encoding for MD5

my next Problem :(

Using the it2be Cryptor Plug-in I am calculating the MD5 of the string ‘test’.
The result is “098f6bcd4621d373cade4e832627b4f6” - this is correct.

For the output format i need the Base64 encoded value of this MD5 string.
The Base64 Encoder from it2be seems to work only with an array of bytes - and not strings ?!?

Code:

var message = ‘test’

var mymd5 = plugins.it2be_cryptor.MD5(message);
application.output(mymd5)

The Base64 Encoding result for ‘test’ must be ‘CY9rzUYh03PK3k6DJie09g==’
How to calculate it ?

Thank you all for your help.

Rainer

Hi Rainer,

I tend to use this util method:

function encodeBase64(_sInputString) {
	var _oEncoder = Packages.org.apache.commons.codec.binary.Base64,
		 _oJString = Packages.java.lang.String;
	return new _oJString(_oEncoder.encodeBase64(new _oJString(_sInputString).getBytes()));
};

No plugins needed.

Hope this helps.