在ASP.NET中实现DES加密与解密MD5加密功能介绍

这篇文章主要介绍了asp.net中des加密与解密md5加密帮助类的实例代码,非常不错,具有参考借鉴价值,需要的朋友可以参考下

public class TrialHelper  {    //默认密钥向量    private static byte[] Keys = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };    ///     /// DES加密字符串    ///     /// 待加密的字符串    /// 加密密钥,要求为8位    /// 加密成功返回加密后的字符串,失败返回源串    public static string EncryptDES( string encryptString, string encryptKey = "" )    {      try      {        if (string.IsNullOrEmpty(encryptKey) || encryptKey.Length     /// DES解密字符串    ///     /// 待解密的字符串    /// 解密密钥,要求为8位,和加密密钥相同    /// 解密成功返回解密后的字符串,失败返源串    public static string DecryptDES( string decryptString, string decryptKey = "" )    {      try      {        if (string.IsNullOrEmpty(decryptKey) || decryptKey.Length     /// MD5数据加密    ///     /// 加密字段    /// 加密后的字符串    public static string GetMD5( string sDataIn )    {      System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();      byte[] bytValue, bytHash;      bytValue = System.Text.Encoding.UTF8.GetBytes(sDataIn);      bytHash = md5.ComputeHash(bytValue);      md5.Clear();      string sTemp = "";      for (int i = 0; i 

    调用:              


//获取登录信息        loginRecord.Name = tbName.Text.Trim();        loginRecord.MD5Pwd = TrialHelper.GetMD5(tbPwd.Password); //保存到数据库MD5加密方式        loginRecord.Pwd = TrialHelper.EncryptDES(tbPwd.Password);//记住密码des加密方式,保存到本地

登录后复制

以上就是在ASP.NET中实现DES加密与解密MD5加密功能介绍的详细内容,更多请关注【创想鸟】其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。

发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2438527.html

(0)
上一篇 2025年3月3日 11:44:07
下一篇 2025年2月25日 22:16:24

AD推荐 黄金广告位招租... 更多推荐

相关推荐

发表回复

登录后才能评论