Java Digest digest(String password)

Here you can find the source of digest(String password)

Description

digest

License

Apache License

Declaration

public static String digest(String password) throws Exception 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.security.MessageDigest;

public class Main {
    public static String digest(String password) throws Exception {
        MessageDigest md = MessageDigest.getInstance("MD5");
        md.update(password.getBytes());//  w ww  .j  av  a  2  s  .  co m

        byte byteData[] = md.digest();

        //convert the byte to hex format method 1
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < byteData.length; i++) {
            sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
        }

        return sb.toString();

    }
}

Related

  1. digest(String input, String algorithm, String encoding)
  2. digest(String key)
  3. digest(String message, byte[] salt)
  4. digest(String name, String source)
  5. digest(String orgin, String algorithm)
  6. digest(String plain, String algorithm)
  7. digest(String planeText)
  8. digest(String provider, File file, int radix)
  9. digest(String raw, String algorithm)