Java Utililty Methods MD5 String

List of utility methods to do MD5 String

Description

The list of methods to do MD5 String are organized into topic(s).

Method

Stringmd5(String input)
md
String result = input;
if (input != null) {
    MessageDigest md = MessageDigest.getInstance("MD5");
    md.update(input.getBytes());
    BigInteger hash = new BigInteger(1, md.digest());
    result = hash.toString(16);
    while (result.length() < 32) {
        result = "0" + result;
...
Stringmd5(String input)
Create an MD5 hash of a string.
if (input == null || input.length() == 0) {
    throw new IllegalArgumentException("Input string must not be blank.");
try {
    MessageDigest algorithm = MessageDigest.getInstance("MD5");
    algorithm.reset();
    algorithm.update(input.getBytes());
    byte[] messageDigest = algorithm.digest();
...
Stringmd5(String input)
Returns a MD5 digest string of the input string.
try {
    MessageDigest md = MessageDigest.getInstance("MD5");
    BigInteger number = new BigInteger(1, md.digest(input.getBytes()));
    String hashtext = number.toString(16);
    while (hashtext.length() < 32) {
        hashtext = "0" + hashtext;
    return hashtext;
...
StringMD5(String inputString)
Used to get the MD5 hash of a given string.
try {
    MessageDigest messageDigest = MessageDigest.getInstance("MD5");
    byte[] array = messageDigest.digest(inputString.getBytes());
    StringBuffer stringBuilder = new StringBuffer();
    for (int i = 0; i < array.length; ++i) {
        stringBuilder.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1, 3));
    return stringBuilder.toString();
...
Stringmd5(String inputText)
md
if (inputText == null || "".equals(inputText.trim())) {
    throw new IllegalArgumentException("please input un-null value");
String encryptText = null;
try {
    MessageDigest m = MessageDigest.getInstance("md5");
    m.update(inputText.getBytes());
    byte s[] = m.digest();
...
byte[]md5(String inStr)
generate 32-bit md5
MessageDigest md5 = null;
try {
    md5 = MessageDigest.getInstance("MD5");
} catch (Exception e) {
    System.out.println(e.toString());
    e.printStackTrace();
    return new byte[0];
char[] charArray = inStr.toCharArray();
byte[] byteArray = new byte[charArray.length];
for (int i = 0; i < charArray.length; i++) {
    byteArray[i] = (byte) charArray[i];
return md5.digest(byteArray);
byte[]md5(String key)
md
MessageDigest algorithm;
try {
    algorithm = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException ex) {
    throw new RuntimeException(ex);
algorithm.reset();
try {
...
byte[]md5(String md5)
md
MessageDigest md = null;
byte bytes[] = md5.getBytes();
try {
    md = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
    e.printStackTrace();
return md.digest(bytes);
...
StringMD5(String md5)
MD
try {
    java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
    byte[] array = md.digest(md5.getBytes());
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < array.length; ++i) {
        sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1, 3));
    return sb.toString();
...
Stringmd5(String message)
Encrypt the passed String using MD5.
try {
    MessageDigest md = MessageDigest.getInstance("MD5");
    return (hex(md.digest(message.getBytes())));
} catch (NoSuchAlgorithmException e) {
return (null);