如何获取asp.net中MD5加密与DES加解密算法的完整示例代码?
- 内容介绍
- 文章标签
- 相关推荐
本文共计558个文字,预计阅读时间需要3分钟。
原文示例:本文实例讲述了ASP.NET实现MD5加密和解密算法类。
改写后:本文展示了如何使用ASP.NET实现MD5加密和解密功能。
本文实例讲述了asp.net实现的MD5加密和DES加解密算法类。分享给大家供大家参考,具体如下:
#region MD5算法 public string md5(string str, int code) { if (code == 32) //32位加密 { return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").ToLower(); } else //16位MD5加密(取32位加密的9~25字符) { return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").ToLower().Substring(8, 16); } } #endregion
#region DESEncrypt DES加密 // <summary> /// 进行DES加密。 /// </summary> /// <param name=”pToEncrypt”>要加密的字符串。
本文共计558个文字,预计阅读时间需要3分钟。
原文示例:本文实例讲述了ASP.NET实现MD5加密和解密算法类。
改写后:本文展示了如何使用ASP.NET实现MD5加密和解密功能。
本文实例讲述了asp.net实现的MD5加密和DES加解密算法类。分享给大家供大家参考,具体如下:
#region MD5算法 public string md5(string str, int code) { if (code == 32) //32位加密 { return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").ToLower(); } else //16位MD5加密(取32位加密的9~25字符) { return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "MD5").ToLower().Substring(8, 16); } } #endregion
#region DESEncrypt DES加密 // <summary> /// 进行DES加密。 /// </summary> /// <param name=”pToEncrypt”>要加密的字符串。

