Java MD5 String md5Encryption(String str)

Here you can find the source of md5Encryption(String str)

Description

md Encryption

License

Apache License

Declaration

public static String md5Encryption(String str) 

Method Source Code


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

import java.security.MessageDigest;
import java.util.Base64;
import java.util.Base64.Encoder;

public class Main {
    /**/*from  w w w. j  ava2s  .co m*/
     * encrypt string with MD5
     * @param str: the string needs to be encrypted
     * @return String: encrypted string
     * @throws
     */
    public static String md5Encryption(String str) {
        byte[] newStr = null;
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            Encoder base = Base64.getEncoder();
            newStr = base.encode(md5.digest(str.getBytes("UTF-8")));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return newStr.toString();
    }
}

Related

  1. md5DigestPassword(String password)
  2. md5EncriptionPassword(String str)
  3. md5encrypt(String phrase)
  4. md5Encrypt(String str)
  5. md5Encrypt(String str)
  6. md5File(File f)
  7. md5file(File file)
  8. md5FromFile(File file)
  9. md5fromFile(String path)