# Base64 Encoding for MD5

**URL:** <https://forum.servoy.com/t/base64-encoding-for-md5/18833>\
**Category:** Classic Servoy\
**Created:** [April 26, 2016, 9:16am UTC](https://forum.servoy.com/t/base64-encoding-for-md5/18833 "2016-04-26T09:16:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rainer](https://avatars.discourse-cdn.com/v4/letter/r/58956e/32.png) [@rainer](https://forum.servoy.com/u/rainer)\
**Post date:** [April 26, 2016, 9:16am UTC](https://forum.servoy.com/t/base64-encoding-for-md5/18833/1 "2016-04-26T09:16:06Z")

</div>

my next Problem ![:(]( "Sad")

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

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [April 26, 2016, 3:24pm UTC](https://forum.servoy.com/t/base64-encoding-for-md5/18833/2 "2016-04-26T15:24:44Z")

</div>

Hi Rainer,

I tend to use this util method:

```auto
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.
