-
MD5
Message Digest algorithm MD5 (Chinese named message Digest Algorithm version fifth) is a hash function widely used in the field of computer security to provide integrity protection for messages. The algorithm's file number is RFC 1321 (R.rivest,mit Laboratory for computer science and RSA Data Security Inc. April 1992). MD5 is message-digest algorithm 5 (Information-Digest algorithm 5), which is used to ensure complete and consistent information transmission. is one of the widely used hashing algorithms (also translation digest algorithm, hashing algorithm), mainstream programming language has been widely MD5 implemented. The calculation of data (such as Chinese characters) as another fixed length value is the basic principle of the hashing algorithm, and the predecessor of MD5 is MD2, MD3 and MD4. The MD5 algorithm has the following characteristics: 1, compressibility: Any length of data, calculated the length of the MD5 value is fixed. 2, easy to calculate: It is easy to calculate the MD5 value from the original data. 3, anti-modification: Any changes to the original data, even if only 1 bytes modified, the resulting MD5 value is very different. 4, strong anti-collision: known raw data and its MD5 value, it is very difficult to find a data with the same MD5 value (that is, falsification of data). MD5 's role is to allow bulk information to be "compressed" into a confidential format before signing a private key with a digital signature software (that is, converting an arbitrary-length byte string into a long hexadecimal string). In addition to MD5, among them the more famous are sha-1, Ripemd and Haval and so on. Java implementation Encryption in Java some login password encryption, need to use MD5 encryption technologyjava.security.MessageDigestThe MD5 class is used to provide an application with an information digest algorithm, such as an algorithm for the. The simple point is that it is used to generate hash codes. The information digest is a secure, one-way hash function that receives data of any size and outputs a fixed-length hash value.messagedigesTIt is instantiated and initialized through its getinstance series of static functions. MessageDigest objects by using the
update
method to process the data. Can be called at any time
reset
method to reset the summary. Once all the data that needs to be updated has been updated, you should call
digest
method to complete the hash calculation and return the result. For a given number of update data,
digest
Method can only be called once.
digest
After the method is called, the MessageDigest object is reset to its initial state.
The following is a cryptographic process code implementation based on the above messagedigest
Public Staticstring GetMd5 (string pwd) {MessageDigest MD=NULL; Try{MD=messagedigest.getinstance ("MD5"); Md.update (Pwd.getbytes ()); } Catch(nosuchalgorithmexception e) {//TODO auto-generated Catch blockE.printstacktrace (); } //returns the Big Data integer, the Go-string return NewBigInteger (1, Md.digest ()). ToString (10); }
MD5 Encryption--java