MD5-related classes:
System. Security. cryptography. MD5
System. Security. cryptography. md5cryptoserviceprovider ()
System. Web. Security. formsauthentication. hashpasswordforstoringinconfigfile (strsource, "MD5 ")
Sha1 related classes:
System. Security. cryptography. sha1
System. Security. cryptography. sha1cryptoserviceprovider ()
System. Web. Security. formsauthentication. hashpasswordforstoringinconfigfile (strsource, "sha1 ")
Obtain the sha1-encrypted string
Public String encrypttosha1 (string Str)
{
Sha1cryptoserviceprovider sha1 = new sha1cryptoserviceprovider ();
Byte [] str1 = encoding. utf8.getbytes (STR );
Byte [] str2 = sha1.computehash (str1 );
Sha1.clear ();
(Sha1 as idisposable). Dispose ();
Return convert. tobase64string (str2 );
}
Bytes ---------------------------------------------------------------------------------------------------------
Obtain the MD5-encrypted string
Public String encrypttomd5 (string Str)
{
Md5cryptoserviceprovider MD5 = new md5cryptoserviceprovider ();
Byte [] str1 = encoding. utf8.getbytes (STR );
Byte [] str2 = md5.computehash (str1, 0, str1.length );
Md5.clear ();
(MD5 as idisposable). Dispose ();
Return convert. tobase64string (str2 );
}
-----------------------------------------------------------------------
These encryption functions are executed on the server. That is to say, when the user enters the password and transfers the data from the client to the server, the user's password is not protected, which is very dangerous. The banking practice is to install ActiveX controls on the client, encrypt some important information on the client, and then send.