We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
MD5 (Read 1220 times)
MD5
Sep 8th, 2006, 12:37am
 
This may be a dumb question but is there a MD5() compression function?
Re: MD5
Reply #1 - Sep 8th, 2006, 12:45am
 
is there MessageDigest stuff?
Re: MD5
Reply #2 - Sep 8th, 2006, 6:17pm
 
sure, it's built into Java. you can use it like this:

Code:
void setup() {
byte[] md5hash = messageDigest("hello world!","MD5");
for(int i=0; i<md5hash.length; i++) print(hex(md5hash[i],2)+":");
}

byte[] messageDigest(String message, String algorithm) {
try {
java.security.MessageDigest md = java.security.MessageDigest.getInstance(algorithm);
md.update(message.getBytes());
return md.digest();
} catch(java.security.NoSuchAlgorithmException e) {
println(e.getMessage());
return null;
}
}


You can also use other digest algoritms, e.g. SHA-1. Google for more... Wink
Re: MD5
Reply #3 - Sep 9th, 2006, 12:07am
 
thanks a lot!
Re: MD5
Reply #4 - Jul 14th, 2009, 11:31am
 
toxi wrote on Sep 8th, 2006, 6:17pm:
 byte[] md5hash = messageDigest("hello world!","MD5");
 for(int i=0; i<md5hash.length; i++) print(hex(md5hash[i],2)+":");

this writes a hexa code like
ff:df:3f:df:2a:.....

but how do i get an MD5-string like
4a492adb6b7fd95ea729e375b93f0da3
Huh
Re: MD5
Reply #5 - Jul 14th, 2009, 11:37am
 
forget it!

i just found out, that md5 is always just hexadecimal numbers Cheesy

so its the Code:
 
byte[] md5hash = messageDigest(filename,"MD5");
String md5string="";
for(int i=0; i<md5hash.length; i++) md5string+=(hex(md5hash[i],2));
print(md5string.toLowerCase());
Page Index Toggle Pages: 1