小编jav*_*ost的帖子

这种C#代码对于分类数据的RSA加密是否安全?

我将加密CLASSIFIED数据,我的数据必须使用最先进的加密保护.我使用AES加密数据,使用RSA加密密钥.我的RSA代码如下.请确认此代码是否安全:

  static class Program
  {
    static void Main()
    {
      var csp = new RSACryptoServiceProvider(3072);
      var privKey = csp.ExportParameters(true);
      var pubKey = csp.ExportParameters(false);
      string pubKeyString;
      {
        var sw = new System.IO.StringWriter();
        var xs = new System.Xml.Serialization.XmlSerializer(typeof(RSAParameters));
        xs.Serialize(sw, pubKey);
        pubKeyString = sw.ToString();
      }
  {
    //get a stream from the string
    var sr = new System.IO.StringReader(pubKeyString);
    //we need a deserializer
    var xs = new System.Xml.Serialization.XmlSerializer(typeof(RSAParameters));
    //get the object back from the stream
    pubKey = (RSAParameters)xs.Deserialize(sr);
  }
  csp = new RSACryptoServiceProvider();
  csp.ImportParameters(pubKey);
  var plainTextData …
Run Code Online (Sandbox Code Playgroud)

c# security encryption cryptography rsa

-3
推荐指数
1
解决办法
562
查看次数

标签 统计

c# ×1

cryptography ×1

encryption ×1

rsa ×1

security ×1