Android uses MD5 encrypted files

Source: Internet
Author: User

private static final int stream_buffer_length = 1024;
private static final String algorithm_md5 = "MD5";

public static String md5file (file file) {if (null = = File) {return ""; } String result = ""; try {messagedigest digest = messagedigest.getinstance (ALGORITHM_MD5); Byte[] digests = Updatedigest (Digest, new FileInputStream (file)). Digest (); BigInteger bi = new BigInteger (1, digests); result = Bi.tostring (16); } catch (NoSuchAlgorithmException e) {e.printstacktrace (); } catch (FileNotFoundException e) {e.printstacktrace (); } catch (IOException e) {e.printstacktrace (); } return result; } public static MessageDigest Updatedigest (Final MessageDigest Digest, final InputStream data) throws IOException { Final byte[] buffer = new Byte[stream_buffer_length]; int read = data.read (buffer, 0, stream_buffer_length); while (Read >-1) {digest.update (buffer, 0, read); Read = data.read (buffer, 0,Stream_buffer_length); } return digest; }

  

Android uses MD5 encrypted files

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.