Java MD5 String md5EncriptionPassword(String str)

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

Description

md Encription Password

License

Open Source License

Declaration

public static String md5EncriptionPassword(String str) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 *
 * Project : Mirage V2//from w  w  w. j  a va2 s  .  c  o  m
 *
 * Package :
 *
 * Date    :  September 19, 2007, 11:31 PM
 *
 * Author  : Praveen Kumar Ralla<pralla@miraclesoft.com>
 *
 * File    : EncriptDecriptPwd.java
 *
 * Copyright 2007 Miracle Software Systems, Inc. All rights reserved.
 * MIRACLE SOFTWARE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 * *****************************************************************************
 */

import java.security.MessageDigest;

public class Main {
    private static MessageDigest digester;

    public static String md5EncriptionPassword(String str) {
        if (str == null || str.length() == 0) {
            throw new IllegalArgumentException("String to encript cannot be null or zero length");
        }

        digester.update(str.getBytes());
        byte[] hash = digester.digest();
        StringBuffer hexString = new StringBuffer();
        for (int i = 0; i < hash.length; i++) {
            if ((0xff & hash[i]) < 0x10) {
                hexString.append("0" + Integer.toHexString((0xFF & hash[i])));
            } else {
                hexString.append(Integer.toHexString(0xFF & hash[i]));
            }
        }
        return hexString.toString();
    }
}

Related

  1. md5digest(String key)
  2. md5Digest(String s)
  3. md5Digest(String text)
  4. md5Digest(String word)
  5. md5DigestPassword(String password)
  6. md5encrypt(String phrase)
  7. md5Encrypt(String str)
  8. md5Encrypt(String str)
  9. md5Encryption(String str)