Android MD5 Encode md5(String s)

Here you can find the source of md5(String s)

Description

md

Declaration

public static String md5(String s) 

Method Source Code

//package com.java2s;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Main {
    public static String md5(String s) {
        return hash(s, "MD5");
    }// w w w. j a va2s  .c  om

    private static String hash(String s, String algorithm) {
        String result = s;
        try {
            MessageDigest digest = MessageDigest.getInstance(algorithm);
            byte[] bytes = digest.digest(s.getBytes());
            BigInteger biggie = new BigInteger(1, bytes);
            result = String
                    .format("%0" + (bytes.length << 1) + "x", biggie);
        } catch (NoSuchAlgorithmException e) {
            // No way...
        }
        return result;
    }
}

Related

  1. md5(File input)
  2. md5(String input)
  3. md5(String ori)
  4. md5(String ori)
  5. md5(String s)
  6. md5(String str)
  7. md5(final String s)
  8. md5(final String s)
  9. md5(final String s)