// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   Md5Encrypt.java

package com.keyshop.shop.order.util;

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

public class Md5Encrypt
{

    public Md5Encrypt()
    {
    }

    public static String md5(String text)
    {
        MessageDigest msgDigest = null;
        try
        {
            msgDigest = MessageDigest.getInstance("MD5");
        }
        catch(NoSuchAlgorithmException e)
        {
            throw new IllegalStateException("System doesn't support MD5 algorithm.");
        }
        msgDigest.update(text.getBytes());
        byte bytes[] = msgDigest.digest();
        String md5Str = new String();
        for(int i = 0; i < bytes.length; i++)
        {
            byte tb = bytes[i];
            char tmpChar = (char)(tb >>> 4 & 0xf);
            char high;
            if(tmpChar >= '\n')
                high = (char)((97 + tmpChar) - 10);
            else
                high = (char)(48 + tmpChar);
            md5Str = md5Str + high;
            tmpChar = (char)(tb & 0xf);
            char low;
            if(tmpChar >= '\n')
                low = (char)((97 + tmpChar) - 10);
            else
                low = (char)(48 + tmpChar);
            md5Str = md5Str + low;
        }

        return md5Str;
    }
}
