Add a text watermark to the picture and verify the picture

Source: Internet
Author: User
Tags md5

Just beginning in a picture, add Chinese or punctuation, and then get the hash value to verify whether the picture is generated from your own system, but find a problem in which the hash value of the picture is not what you changed in the picture it will change, it needs to change to a certain extent before it changes, And the transparency cannot be 0.0f, if just want to play in the picture of a mark that you know, not to show to others to see, with the hash of the judge is unable to judge the picture, and then looked up some data, try to get the picture of MD5, after trying to find this can replace the hash value to judge the picture, And this will not change because the amount of markup is small, or the transparency is 0.0f, the code is as follows:

Use the following method to get the MD5 of the file, and then use this to determine if you are marking the picture.

   public static String getFileMD5 (file file) {
		  //To determine if there is a file
	    if (!file.isfile ()) {return
	      null;
	    }
	    Create a digest algorithm object
	    messagedigest digest = null;
	    FileInputStream In=null;
	    byte buffer[] = new byte[1024];
	    int Len;
	    try {
	      digest = messagedigest.getinstance ("MD5");
	      in = new FileInputStream (file);
	      while (len = in.read (buffer, 0, 1024))!=-1) {
	        digest.update (buffer, 0, Len);
	      }
	      In.close ();
	    } catch (Exception e) {
	      e.printstacktrace ();
	      return null;
	    }
	    BigInteger bigInt = new BigInteger (1, Digest.digest ());
	    return bigint.tostring ();
	  








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.