Some uses of MD5

Source: Internet
Author: User

 PackageMD5;Importjava.security.MessageDigest;Importjava.security.NoSuchAlgorithmException;/** MD5 Algorithm*/ Public classMD5 {//Global Array    Private Final StaticString[] strdigits = {"0", "1", "2", "3", "4", "5",            "6", "7", "8", "9", "a", "B", "C", "D", "E", "F", "+", "-" };  PublicMD5 () {}//returns the form of a number followed by a string    Private StaticString bytetoarraystring (bytebbyte) {        intIRet =Bbyte; //System.out.println ("iret=" +iret);        if(IRet < 0) {IRet+ = 256; }        intID1 = IRET/16; intiD2 = iRet% 16; returnSTRDIGITS[ID1] +Strdigits[id2]; }    //return form is only numeric    Private StaticString Bytetonum (bytebbyte) {        intIRet =Bbyte; System.out.println ("Iret1=" +IRet); if(IRet < 0) {IRet+ = 256; }        returnstring.valueof (IRet); }    //convert byte array to 16 binary string    Private StaticString bytetostring (byte[] bbyte) {StringBuffer Sbuffer=NewStringBuffer ();  for(inti = 0; i < bbyte.length; i++) {sbuffer.append (bytetoarraystring (bbyte[i)); }        returnsbuffer.tostring (); }     Public Staticstring Getmd5code (String strobj) {string resultstring=NULL; Try{resultstring=NewString (strobj); MessageDigest MD= Messagedigest.getinstance ("MD5"); //md.digest () The function returns a byte array that holds the result of the hash valueResultstring =bytetostring (Md.digest (Strobj.getbytes ())); } Catch(NoSuchAlgorithmException ex) {ex.printstacktrace (); }        returnresultstring; }    //Reversible encryption Algorithm     Public Staticstring KL (String inStr) {//string s = new string (INSTR);      Char[] A =Instr.tochararray ();  for(inti = 0; i < a.length; i++) {A[i]= (Char) (A[i] ^ ' t '); } String S=NewString (a); returns; }            //decryption after encryption     Public Staticstring JM (String inStr) {Char[] A =Instr.tochararray ();  for(inti = 0; i < a.length; i++) {A[i]= (Char) (A[i] ^ ' t '); } String k=NewString (a); returnK; }        Public Static voidMain (string[] args) {MD5 getMD5=NewMD5 (); String Str= "a";        SYSTEM.OUT.PRINTLN (Getmd5.getmd5code (str));        SYSTEM.OUT.PRINTLN (GETMD5.KL (str));    System.out.println (GETMD5.JM (KL (str))); }}

Each user registration, give the user a GUID, and then put this GUID according to their own algorithm to do something, such as take a few, or the GUID to do md5,sha such as encryption, then take out 6 bits, the 6 bits as a key, the user's password to do des encryption.
You can also put the GUID after the encryption of some characters in the location of the salt, add to the user password, and then do Md5,sha and other encryption. You can also consider adding special symbols to the global array

Login verification can consider adding a user MD5 code generated 2 operations, and then saved to the database, the front-end authentication passed MD5 code, and then 2 operations in the background for the database validation.

Some uses of MD5

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.