Java MD5 String md5crypt(String s)

Here you can find the source of md5crypt(String s)

Description

mdcrypt

License

Open Source License

Declaration

public static String md5crypt(String s) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.security.MessageDigest;

public class Main {
    private static MessageDigest md5 = null;
    private static StringBuffer digestBuffer = null;

    public static String md5crypt(String s) {
        System.out.println(s);/*from   www. j  ava  2  s.  co  m*/
        digestBuffer.setLength(0);
        byte abyte0[] = md5.digest(s.getBytes());
        for (int i = 0; i < abyte0.length; i++)
            digestBuffer.append(toHex(abyte0[i]));

        return digestBuffer.toString();
    }

    private static String toHex(byte one) {
        String HEX = "0123456789ABCDEF";
        char[] result = new char[2];
        result[0] = HEX.charAt((one & 0xf0) >> 4);
        result[1] = HEX.charAt(one & 0x0f);
        return new String(result);
    }
}

Related

  1. md52(String string)
  2. MD5_HEX(String source)
  3. md5AsHexString(String text, String charset)
  4. md5Base64(String str)
  5. md5ByHex(String src)
  6. md5Digest(final InputStream data)
  7. md5Digest(final String message)
  8. md5digest(String key)
  9. md5Digest(String s)