asp.net with C # using MD5,SHA1 encryption

Source: Internet
Author: User
Tags hash md5 md5 encryption regular expression sha1 sha1 encryption
asp.net| Encryption/****** Snow Dragon Original *******/
All rights reserved, shall not be reproduced at the end of the author's consent

Today's experiment is relatively smooth, the morning regular expression used very cool, evening MD5 and SHA1 encryption is no difficulty on the use, the following is the experimental summary (washing machine washing clothes, the opportunity to write something online).

Add encryption Knowledge First: MD5 and SHA1 are hash encryption techniques, the so-called hashing encryption is no matter what your input string is, how long, after the encryption has become the only fixed length of the encryption string, MD5 encryption after the length of the string has 16-bit and 32-bit two, SHA1 I counted a bit today has 40, This encryption is characterized by the way the encryption is made public, but you can not reverse, to crack can only be exhaustive, the difficulty is great, theoretically 8-bit password combination has (26 letters +10 digits +21 commonly used English symbols) 8 times of the possible, with the current relatively good machine machine to count more than a year. But recently MD5 heard was cracked, can quickly hit the password, but the crack machine has not been circulated, general application is still possible, SHA1 is relatively safe.

Hash encryption, represented by a function is such a y=f (x), x is the input of the string, F is the algorithm, Y is encrypted after the secret string, F is public, the so-called unique x only corresponds to the only y,x only users know, so y is the only, now cracked MD5 is found that a few x can correspond to Y, And you can quickly find x from Y.

Encryption technology is also popular for authentication of public key encryption, interested friends can refer to the relevant encryption books.

Using MD5 in C # is very simple, using the following static method:
System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile (Temp_str, "MD5");
You can get the encrypted string, the static method is very simple, temp_str is the string variable you want to encrypt, "MD5" means to use MD5 encryption, if you use the "SHA1", is to use SHA1 encryption, easy enough, quickly put your password verification encryption bar.

From the above we can understand that C # is really worthy of the name of Microsoft's Zhen Shan Bao, the provision of namespaces covers the various aspects of our common, you are still waiting for, come with me to learn C # bar.

I have been studying the use of WinForm custom controls in C # for some time, and now I can write my own custom control, and feel that its proxy mechanism and subscription mechanism are very good, Then I want to use this part of the knowledge in asp.net, to see how the Web Custom control usage, if you also want to know, please look forward to my next report!




Related Article

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.