Java MD5 String md5Base64(String str)

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

Description

md Base

License

Apache License

Declaration

public static String md5Base64(String str) 

Method Source Code

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

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

import sun.misc.BASE64Encoder;

public class Main {

    public static String md5Base64(String str) {
        try {// www.  ja  v  a  2  s.c o  m
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            return base64Encode(md5.digest(str.getBytes()));
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return null;
    }

    public static String base64Encode(byte[] b) {
        if (b == null) {
            return null;
        }
        return new BASE64Encoder().encode(b);
    }
}

Related

  1. md5(String... args)
  2. MD5(String... texts)
  3. md52(String string)
  4. MD5_HEX(String source)
  5. md5AsHexString(String text, String charset)
  6. md5ByHex(String src)
  7. md5crypt(String s)
  8. md5Digest(final InputStream data)
  9. md5Digest(final String message)