Android MD5 Encode checkDicMD5(String dicFile, final byte[] expected)

Here you can find the source of checkDicMD5(String dicFile, final byte[] expected)

Description

check Dic MD

Declaration

public static boolean checkDicMD5(String dicFile, final byte[] expected) 

Method Source Code

//package com.java2s;
import java.io.FileInputStream;
import java.io.InputStream;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.util.Arrays;

public class Main {
    public static boolean checkDicMD5(String dicFile, final byte[] expected) {
        try {//  www. j  a v a 2s .c o  m
            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)
                    ;
            } finally {
                is.close();
            }
            final byte[] hash = md.digest();
            return Arrays.equals(hash, expected);
        } catch (Exception e) {
            return false;
        }

    }
}

Related

  1. md5Hex(String str)
  2. computeHashMD5(final String text)
  3. getMD5String(File file)
  4. getMD5String(String str)
  5. getMd5(byte... values)
  6. MD5(String md5)
  7. getMD5Str(String str)
  8. MD5(String text)
  9. stringGetMD5String(String s)