Java MD5 String MD5(String... texts)

Here you can find the source of MD5(String... texts)

Description

MD

License

Apache License

Declaration

public static String MD5(String... texts) throws Exception 

Method Source Code

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

import java.security.MessageDigest;

public class Main {
    private static final char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd',
            'e', 'f' };

    public static String MD5(String... texts) throws Exception {
        try {//from w w w  .  j  a v a  2  s.  c  om

            if (texts == null || texts.length == 0)
                return null;
            MessageDigest messageDigest = MessageDigest.getInstance("MD5");
            for (String tt : texts)
                messageDigest.update(tt.getBytes());
            byte[] updateBytes = messageDigest.digest();
            int len = updateBytes.length;
            char myChar[] = new char[len * 2];
            int k = 0;
            for (int i = 0; i < len; i++) {
                byte byte0 = updateBytes[i];
                myChar[k++] = hexDigits[byte0 >>> 4 & 0x0f];
                myChar[k++] = hexDigits[byte0 & 0x0f];
            }
            return new String(myChar);
        } catch (Exception e) {
            throw e;
        }
    }
}

Related

  1. md5(String value)
  2. md5(String value)
  3. md5(String value)
  4. md5(String value)
  5. md5(String... args)
  6. md52(String string)
  7. MD5_HEX(String source)
  8. md5AsHexString(String text, String charset)
  9. md5Base64(String str)