/// Encrypts the given [data] with RSA using the specified [key]. public static byte[] encryptBytesWithRsa(byte[] data, PublicKey key) { RSAcoder coder = new RSAcoder((AsymmetricKeyParameter)((RSAPublicKey)key).pubKey); return(coder.Encrypt(data)); }
/// Decrypts the given data using the specified private [key]. public static byte[] decryptBytesWithRsa(byte[] data, PrivateKey key) { RSAcoder coder = new RSAcoder((AsymmetricKeyParameter)((RSAPrivateKey)key).secretKey); return(coder.Decrypt(data)); }
/// Encrypts the given [data] with RSA using the specified [key]. public static byte[] encryptStringWithRsa(String data, PublicKey key) { RSAcoder coder = new RSAcoder((AsymmetricKeyParameter)((RSAPublicKey)key).pubKey); return(coder.Encrypt(System.Text.Encoding.UTF8.GetBytes(data))); }