Android Utililty Methods MD5 Encode

List of utility methods to do MD5 Encode

Description

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

Method

byte[]md5Byte(String in)
Returns a byte array representation of the hash of a string input using the MD5 hashing algorithm.
return digestByte("MD5", in.getBytes());
byte[]md5Byte(byte[] in)
Returns a byte array representation of the hash of a byte array input using the MD5 hashing algorithm.
return digestByte("MD5", in);
Stringmd5File(File file)
md File
if (!file.isFile()) {
    return null;
MessageDigest digest = null;
FileInputStream in = null;
byte buffer[] = new byte[1024];
int len;
try {
...
Stringmd5Hex(String str)
md Hex
final byte[] digested = md5(str);
if (digested == null)
    return "";
return toHex(digested);
StringcomputeHashMD5(final String text)
Returns a hash value for a string using MD5 algorithm
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(text.getBytes(), 0, text.length());
byte hashData[] = md.digest();
StringBuilder sb = new StringBuilder(hashData.length * 2);
for (int i = 0; i < hashData.length; i++) {
    int b = (0xFF & hashData[i]);
    if (b <= 0xF)
        sb.append('0');
...
StringgetMD5String(File file)
Get a File's HashCode
MessageDigest md5;
try {
    md5 = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
    return null;
InputStream in = null;
byte[] buffer = new byte[1024];
...
StringgetMD5String(String str)
Get a String's HashCode
MessageDigest md5;
try {
    md5 = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
    return null;
md5.update(str.getBytes());
return convertToHexString(md5.digest());
...
StringgetMd5(byte... values)
get Md
String cacheKey;
try {
    final MessageDigest mDigest = MessageDigest.getInstance("MD5");
    mDigest.update(values);
    cacheKey = bytesToHexString(mDigest.digest());
} catch (NoSuchAlgorithmException e) {
    cacheKey = String.valueOf(Arrays.hashCode(values));
return cacheKey;
booleancheckDicMD5(String dicFile, final byte[] expected)
check Dic MD
try {
    MessageDigest md = MessageDigest.getInstance("MD5");
    InputStream is = new FileInputStream(dicFile);
    try {
        is = new DigestInputStream(is, md);
        byte[] buffer = new byte[16384];
        while (is.read(buffer) != -1)
            ;
...
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));
...