相关疑难解决方法(0)

在C#中实现RSA

我目前正在尝试使用RSACrytoServiceProveider类实现一个类来处理我的应用程序实例之间的安全通信.第一个问题:实现单个类来处理发送者/接收者角色或者我应该将角色分成单个类是一个好主意吗?这是我到目前为止所做的:

using System;
using System.Text;
using System.Security.Cryptography;

namespace Agnus.Cipher
{
    public class RSA
    {
        private byte[] plaintextBytes;
        private byte[] ciphertextBytes;
        private RSACryptoServiceProvider rSAProviderThis;
        private RSACryptoServiceProvider rSAProviderOther;

        public string PublicKey
        {
            get { return rSAProviderThis.ToXmlString(false); }
        }

        public RSA()
        {
            rSAProviderThis = new RSACryptoServiceProvider { PersistKeyInCsp = true }; 
            plaintextBytes = Encoding.Unicode.GetBytes(PublicKey);
        }

        public void InitializeRSAProviderOther(string parameters)
        {
            rSAProviderOther.FromXmlString(parameters);
        }

        public byte[] Encrypt()
        {
            return rSAProviderThis.Encrypt(plaintextBytes, true);
        }
        public byte[] Decrypt()
        {
            return rSAProviderThis.Decrypt(ciphertextBytes, true);
        }
        public byte[] Sign()
        {
            using …
Run Code Online (Sandbox Code Playgroud)

c# rsa rsacryptoserviceprovider

7
推荐指数
1
解决办法
3万
查看次数

标签 统计

c# ×1

rsa ×1

rsacryptoserviceprovider ×1