Get the App
SLTechnology News&Howtos  ›  Development  › 

How to analyze the implementation of MD5 and SHA1 encryption in C # encryption

Shulou Source: shulou.com Published: 2022-06-02 11:43:27 10月20日 Update

How to analyze the implementation of MD5 and SHA1 encryption in C# encryption, many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can get something.

As for the understanding of C # encryption, MD5 and SHA1 encryption can be easily carried out in C #, so what are the specific implementation steps? What should we pay attention to when we do MD5 and SHA1 encryption in C #? Then let's take a look at the specific implementation method and process.

<% @ Import Namespace= "System.Web.Security"% > FormsAuthentication.HashPasswordForStoringInConfigFile

It only takes two steps, the * step introduces the namespace (the namespace can also be omitted), and the second step executes the encryption function.

FormsAuthentication.HashPasswordForStoringInConfigFile has two parameters: * parameters are strings to be encrypted, and optional values for the second parameter are MD5 and SHA1, indicating which encryption method to use. Returns the encrypted string. Note that the returned string is uppercase.

C# encryption exampl

<% @ Page Language= "C#"% > <% @ Import Namespace= "System.Web.Security"% > < script runat= "server" > void Enc (object sender, EventArgs e) {md5Text.Text = FormsAuthentication.HashPasswordForStoringInConfigFile (md5Text.Text, "MD5"); sha1Text.Text = FormsAuthentication.HashPasswordForStoringInConfigFile (sha1Text.Text, "SHA1") } < / script > < html xmlns=" http://www.w3.org/1999/xhtml" > < head runat= "server" > < title > ASP.NET execute MD5 and SHA1 encryption < / title > < / head > < body > < form id= "form1 "runat=" server "> < div > plaintext: < asp:TextBox ID=" plainText "runat=" server "> < / asp:TextBox > < asp:Button ID=" btn "runat=" server "Text=" encrypt "OnClick=" Enc "/ > < / div > < div > MD5 ciphertext: < asp:TextBox ID=" md5Text "runat=" server "Width=" 400 "> < / asp:TextBox > < / div > < div > SHA1 ciphertext: < asp:TextBox ID=" sha1Text "runat=" server " Width= < / asp:TextBox > < / div > < / form > < / body > < / html > is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Tags: Encryption caching parameters characters string name ciphertext method space help analysis clarity two content function uppercase for this article novice plaintext Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Xiaomi NVidia Linux Docker