Java MD5 String md5(String key)

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

Description

md

License

Apache License

Declaration

public static byte[] md5(String key) 

Method Source Code


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

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Main {
    public static byte[] md5(String key) {
        MessageDigest algorithm;// www.j ava 2 s .  c  o  m
        try {
            algorithm = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException ex) {
            throw new RuntimeException(ex);
        }

        algorithm.reset();
        try {
            algorithm.update(key.getBytes("UTF-8"));
        } catch (UnsupportedEncodingException ex) {
            throw new RuntimeException(ex);
        }

        return algorithm.digest();
    }
}

Related

  1. md5(String input)
  2. MD5(String input)
  3. MD5(String inputString)
  4. md5(String inputText)
  5. md5(String inStr)
  6. md5(String md5)
  7. MD5(String md5)
  8. md5(String message)
  9. MD5(String message)