示例#1
0
        /// 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));
        }
示例#2
0
        /// 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));
        }
示例#3
0
        /// 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)));
        }