开发者社区> 问答> 正文

求asp.net C#使用rsa加密的简单完整例子

求asp.net C#使用rsa加密的简单完整例子

展开
收起
知与谁同 2018-07-15 14:26:23 1908 0
3 条回答
写回答
取消 提交回答
  • 杀人者,打虎武松也。
    http://www.cnblogs.com/lizhiwen/archive/2007/09/07/884172.html
    这个是否你想要的
    2019-07-17 22:56:26
    赞同 展开评论 打赏
  • http://www.cnblogs.com/lizhiwen/archive/2007/09/07/884172.html
    这个是否你想要的
    2019-07-17 22:56:26
    赞同 展开评论 打赏
  • 有一个加密算法,采用密钥加密的。
    using System.Security.Cryptography;
    //加密
    public static String JiaMi(String str)
    {
    String encryptKey = "Oyea";
    DESCryptoServiceProvider descsp = new DESCryptoServiceProvider();
    byte[] key = Encoding.Unicode.GetBytes(encryptKey);
    byte[] data = Encoding.Unicode.GetBytes(str);
    System.IO.MemoryStream MStream = new System.IO.MemoryStream();
    CryptoStream CStream = new CryptoStream(MStream, descsp.CreateEncryptor(key, key), CryptoStreamMode.Write);
    CStream.Write(data, 0, data.Length);
    CStream.FlushFinalBlock();
    return Convert.ToBase64String(MStream.ToArray());
    }
    //解密
    public static String JieMi(String str)
    {
    String encryptKey = "Oyea";
    DESCryptoServiceProvider descsp = new DESCryptoServiceProvider();
    byte[] key = Encoding.Unicode.GetBytes(encryptKey);
    byte[] data = Convert.FromBase64String(str);
    System.IO.MemoryStream MStream = new System.IO.MemoryStream();
    CryptoStream CStream = new CryptoStream(MStream, descsp.CreateDecryptor(key,key), CryptoStreamMode.Write);
    CStream.Write(data, 0, data.Length);
    CStream.FlushFinalBlock();
    return Encoding.Unicode.GetString(MStream.ToArray());
    }
    这个看的懂吧
    2019-07-17 22:56:26
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
基于可信计算与加密计算 打造云上原生计算安全 立即下载
\"视频服务特色解决方案——直播连麦与点播加密 \" 立即下载
量子加密通信技术 立即下载