Android examples for java.math:BigInteger
Convert String to MD5 string via BigInteger
import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main{ public static String md5(String s) { MessageDigest m = null;//from w w w.j ava 2 s . c o m try { m = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } m.update(s.getBytes()); String hash = new BigInteger(1, m.digest()).toString(16); return hash; } public static String md5(long l) { return md5(Long.toString(l)); } public static String md5(int i) { return md5(Integer.toString(i)); } }