Base64 Encoding for MD5

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

Base64 Encoding for MD5

Postby rainer » Tue Apr 26, 2016 11:16 am

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
rainer
 
Posts: 11
Joined: Fri Aug 17, 2012 9:58 am

Re: Base64 Encoding for MD5

Postby ROCLASI » Tue Apr 26, 2016 5:24 pm

Hi Rainer,

I tend to use this util method:
Code: Select all
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.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 9 guests