Android MD5 Encode md5(String ori)

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

Description

md

Parameter

Parameter Description
ori a parameter

Return

32 length String; if fails, then return ori String.

Declaration

public static String md5(String ori) 

Method Source Code

//package com.java2s;

import java.math.BigInteger;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Main {
    /**/*from   w ww.  ja  v a 2s  .c  om*/
     * 
     * @param ori
     * @return 32 length String; if fails, then return ori String. 
     */
    public static String md5(String ori) {
        try {
            MessageDigest md = MessageDigest.getInstance("md5");
            md.update(ori.getBytes(), 0, ori.length());
            byte[] bytes = md.digest();
            BigInteger i = new BigInteger(1, bytes);
            return String.format("%1$032x", i);
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            return ori;
        }
    }
}

Related

  1. computeMd5Hash(byte[] in)
  2. MD5(String md5)
  3. MD5(String text)
  4. md5(File input)
  5. md5(String input)
  6. md5(String ori)
  7. md5(String s)
  8. md5(String s)
  9. md5(String str)