public static byte[] Decrypt(IExchangeDecrypt exchangeDecrypt, byte[] value) { if (exchangeDecrypt.ExchangeAlgorithm == ExchangeAlgorithm.Rsa2048) { return(Rsa2048.Decrypt(exchangeDecrypt.PrivateKey, value)); } return(null); }
public static byte[] Encrypt(IExchangeEncrypt exchangeEncrypt, byte[] value) { if (exchangeEncrypt.ExchangeAlgorithm == ExchangeAlgorithm.Rsa2048) { return(Rsa2048.Encrypt(exchangeEncrypt.PublicKey, value)); } return(null); }
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; } }