Another Google search turned up the fact that this code (actually some other
code that is very similar to this) would omit leading zeroes when it prints the
md5 hash. That information might also be of some use to anyone thinking of
using the code. Some strings that should produce a hash with a leading zero
are: "minute", "hash", "a" and "shuttle". Thanks for posting the code. It gives
me something a lot more useful than a "hello world" program to toy around with
java with.
Bill
On Tue, 22 Nov 2011 12:07:18 -0600, John McKown wrote:
>I'm an idiot again. That is just an example. It doesn't actually process an
>input file. But hopefully it is of some use for thinking about the problem.
>
>John McKown
>
-- snip --
>> Java comes with z/OS for "no cost" (other than the CPU to run
>> it). A fast Google search turned up this code:
>>
>> import java.security.*;
>> import java.math.*;
>>
>> public class MD5 {
>> public static void main(String args[]) throws Exception{
>> String s="This is a test";
>> MessageDigest m=MessageDigest.getInstance("MD5");
>> m.update(s.getBytes(),0,s.length());
>> System.out.println("MD5: "+new
>> BigInteger(1,m.digest()).toString(16));
>> }
>> }
>>
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html