0

Possible Duplicates:
Generate MD5 hash in Java
using Java to get a file's md5 checksum?

Hi boys,

how can i generate a MD5 from a file using java?

1
  • 1
    @Ignacio Vazquez-Abrams: that's a pessimistic use of "possibly" :) Commented Dec 3, 2010 at 14:14

1 Answer 1

3

Here's one way.

public static String md5(String s) { MessageDigest md5; try { md5 = MessageDigest.getInstance("MD5"); md5.update(s.getBytes()); return new BigInteger(1, md5.digest()).toString(16); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException(e); } } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.