User Tools

Site Tools


java:createmd5hashinjavawithspring

Differences

This shows you the differences between two versions of the page.


Previous revision
java:createmd5hashinjavawithspring [2022/12/02 22:02] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +====== Create a md5 hash in java with eclipse ======
  
 +Spring does have a not-well-known utility called 
 +[[http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/util/DigestUtils.html|DigestUtils]] who allows
 +you to create md5 hashes easily. Here is an example:
 +
 +<code>
 +import org.springframework.util.DigestUtils;
 +
 +public class Example
 +{
 +
 +public static void main( String[] args )
 +{
 +  System.out.println(  DigestUtils.md5DigestAsHex( "Hello world".getBytes() )  );
 +} // main
 +
 +}
 +
 +</code>
 +
 +
 +However, bear in mind that the javadoc says that //"Mainly for internal use within the framework; consider Apache Commons Codec for a more comprehensive suite of digest utilities"//.