When I was in college, I did not care about whether the passwords were stored in plain text. Now, when I arrived at the company, it must be different. Csdn uses plaintext to store passwords. So now the system is running and all the passwords are encrypted. Fortunately, the existing MD5 encryption has been provided in. net.AlgorithmTo call a simple function.
1. Reference a namespace
Using system. Security. authentication;
2. Compile the encryption function. Here is an example. It is estimated that there are still many methods. These methods are nothing more than replacing the strings. They are similar in nature. Obviously, one is enough.
Public static string getmd5 (string Str) {byte [] B = system. text. encoding. default. getbytes (STR); B = new system. security. cryptography. md5cryptoserviceprovider (). computehash (B); string ret = ""; for (INT I = 0; I <B. length; I ++) {RET + = B [I]. tostring ("X "). padleft (2, '0');} return ret ;}
3. You can call this function by passing in the password entered by the user. Call this function to obtain the function return value, which is a string.
In my opinion, the login process should be as follows:
1. Determine whether the user has entered the verification code
2. Determine whether the user has entered the user name and password
3. Perform MD5 encryption on the user's password
4. query the database with the user name and the encrypted string to check whether there are any results.
5. If the result is successful, it will fail.
After MD5 encryption is seen on the internet, it cannot be easily decrypted. Fortunately, no matter how many times the same string is encrypted with MD5, the results are the same. Therefore, when creating a user, it is necessary to encrypt the password with MD5, so that the database stores all the MD5 encrypted strings for matching. The Administrator has higher permissions and does not know the user's password. This ensures security. In other words, the quality of administrators in these years is not flattering.