Page 1 of 1
Generate MD5 in a server module (Windows)
Posted: Tue Dec 20, 2016 2:49 pm
by andrewli
Hi,
Is there any way to easily generate an MD5 hash from a string, in a server module?
A cross-platform way would be nice (ie would work on IBM i & Windows), but I would be happy if it works just on Windows for now.
Re: Generate MD5 in a server module (Windows)
Posted: Tue Dec 20, 2016 5:26 pm
by soa
There is a Hash service in LANSA Integrater.
Re: Generate MD5 in a server module (Windows)
Posted: Tue Dec 20, 2016 5:44 pm
by andrewli
Thanks, but is there a solution that would work without integrator?
Re: Generate MD5 in a server module (Windows)
Posted: Wed Dec 21, 2016 1:18 am
by jyoung
I am not aware of one that you can use directly in LANSA without Integrator. Also, with Integrator, I believe the Hash service is not in the "normal" version and requires a specific license. If you look at your server licenses, you will see what you have access to.
Wish they would make it available as some HTTP requests (like AWS) require signed URLs which require the use of the HashService.
Re: Generate MD5 in a server module (Windows)
Posted: Wed Dec 21, 2016 9:18 am
by soa
I have an example that works in ILE RPG which can be called from LANSA but that's no good for windows.
Re: Generate MD5 in a server module (Windows)
Posted: Wed Dec 21, 2016 6:43 pm
by HMJust
As you are running on Windows, and do not wish to use the Lansa Integrator, I would suggest using a .NET component.
http://docs.lansa.com/14/en/lansa015/in ... 4_0300.htm
I haven't done this myself, but I understand that should be possible.
The standard MD5 component is documented here:
https://msdn.microsoft.com/en-us/librar ... .110).aspx
PS: I understand that you are asking for MD5 and the link above is to generate MD5.
If you have the opportunity to choose a different hashing function I suggest you look at SHA256 or better (
https://msdn.microsoft.com/en-us/librar ... .110).aspx) as MD5 has already been found to have collisions and SHA1 has at least some theoretical collisions.
PPS:
If you end up using Lansa Integrator I have just now finished a proof of concept for myself which I have documented here:
https://lansa123.wordpress.com/2016/12/ ... shservice/ It would be trivial to change the hashing function from SHA256 to MD5.
Re: Generate MD5 in a server module (Windows)
Posted: Thu Dec 22, 2016 6:58 am
by andrewli
Thank you for that, I will try your Integrator solution.
Re: Generate MD5 in a server module (Windows)
Posted: Wed Jan 04, 2017 2:52 pm
by nazirul_fitri
Does anyone have an example how to generate the md5?? even the simple one will help. Please

Re: Generate MD5 in a server module (Windows)
Posted: Wed Jan 04, 2017 7:44 pm
by HMJust
If you look at my example at
https://lansa123.wordpress.com/2016/12/ ... shservice/ you can just replace the SHA256 with MD5. That should work.
Remember, only use MD5 if it is an external requirement. Use SHA256 or better if you need cryptographic protection.