[My ASP.NET Learning History] Simple encryption method for call class library library

xiaoxiao2021-03-06  57

ASP.NET comes with an MD5 and SHA1 encryption class libraries! Below is two encryption methods to call this class: =============================== PUBLIC STRING GETMD5 (STRING STRDATA) {// Using MD5 encryption method: system. Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider (); byte [] md5Bytes = System.Text.Encoding.Default.GetBytes (strData); byte [] cryString = md5.ComputeHash (md5Bytes); string md5Str = string.empty; for (int i = 0; i

Public String getEncrypt (String strdata, string string string) {// encryption method using the MD5 or SHA1 in the key value hash algorithm: string strcrydata = string.empty; if (strPe.toupper () == "sha1") {strcrydata = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile (strData, "SHA1");} else if (strType.ToUpper () == "MD5") {strCryData = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile (strData, "MD5 ");} Return strcrydata;

public string GetSHA256 (string strData) {// use SHA256 cryptographic algorithms: sha256 = new System.Security.Cryptography.SHA256Managed System.Security.Cryptography.SHA256 (); byte [] sha256Bytes = System.Text.Encoding.Default.GetBytes ( strData); byte [] cryString = sha256.ComputeHash (sha256Bytes); string sha256Str = string.Empty; for (int i = 0; i

public string GetSHA384 (string strData) {// use SHA384 cryptographic algorithms: System.Security.Cryptography.SHA384 sha384 = new System.Security.Cryptography.SHA384Managed (); byte [] sha384Bytes = System.Text.Encoding.Default.GetBytes ( strData); byte [] cryString = sha384.ComputeHash (sha384Bytes); string sha384Str = string.Empty; for (int i = 0; i

转载请注明原文地址:https://www.9cbs.com/read-113553.html

New Post(0)