SHA Information Summary

Source: Internet
Author: User
Tags sha1

The SHA algorithm is evolved on the basis of MD4, and a fixed-length summary information can be obtained by the SHA algorithm.

The SHA Algorithm series has SHA-1 (also known as Sha), sha-224,sha-256,sha-384, and SHA-512, which are usually named after the four algorithms in the following five algorithms and are called SHA-2 algorithms.


The difference between SHA and MD algorithms is mainly in the summary length, the summary length of SHA algorithm is longer, the security is higher
length description of the SHA algorithm SHA algorithm implementation (similar to MD5 implementation) 1. MessageDigest Class of Java comes withNote: only supportsha-1,sha-256,sha-384 and SHA-512Using the Java-MessageDigest class implementation of the SHA and implementation of the MD5, the concrete implementation of the example code
/*** SHA1 Implementation message digest     */Public static byte[] SHA1 () throws exception{messagedigest SHA1 = MessageDigest. getinstance ("SHA"); //Note here to fill Sha instead of SHA1 byte[] result = Sha1.digest ("China". GetBytes ("GBK"));System. out. println (result. Length); return result;    }            /*** SHA1 Implementation message digest     */Public static byte[] SHA256 () throws exception{messagedigest SHA1 = MessageDigest. getinstance ("SHA-256"); //Other SHA2 algorithms in the same vein byte[] result = Sha1.digest ("China". GetBytes ("GBK"));System. out. println (result. Length); return result;    }
2. Apache's Message Digest tool class Org.apache.commons.codec.digest.DigestUtils implementation digestutils. sha256 ("China". GetBytes ("GBK"));Other digest function names are used by analogy with the algorithm name



From for notes (Wiz)



SHA Information Summary

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.