Exemplo n.º 1
0
        public static byte[] Decrypt(IExchangeDecrypt exchangeDecrypt, byte[] value)
        {
            if (exchangeDecrypt.ExchangeAlgorithm == ExchangeAlgorithm.Rsa2048)
            {
                return(Rsa2048.Decrypt(exchangeDecrypt.PrivateKey, value));
            }

            return(null);
        }
Exemplo n.º 2
0
        public static byte[] Encrypt(IExchangeEncrypt exchangeEncrypt, byte[] value)
        {
            if (exchangeEncrypt.ExchangeAlgorithm == ExchangeAlgorithm.Rsa2048)
            {
                return(Rsa2048.Encrypt(exchangeEncrypt.PublicKey, value));
            }

            return(null);
        }
Exemplo n.º 3
0
        public Exchange(ExchangeAlgorithm exchangeAlgorithm)
        {
            this.CreationTime      = DateTime.UtcNow;
            this.ExchangeAlgorithm = exchangeAlgorithm;

            if (exchangeAlgorithm == ExchangeAlgorithm.Rsa2048)
            {
                byte[] publicKey, privateKey;

                Rsa2048.CreateKeys(out publicKey, out privateKey);

                this.PublicKey  = publicKey;
                this.PrivateKey = privateKey;
            }
        }