示例#1
0
        //RSA
        public static byte[] RSAEnc(byte[] data, byte[] key)
        {
            var keyParser = new AsnKeyParser(key);
            var publicKey = keyParser.ParseRSAPublicKey();

            var csp = new CspParameters {ProviderType = 1, KeyNumber = 1};

            var rsa = new RSACryptoServiceProvider(csp) {PersistKeyInCsp = false};
            rsa.ImportParameters(publicKey);
            byte[] enc = rsa.Encrypt(data, false);
            rsa.Clear();
            return enc;
        }
示例#2
0
        public static byte[] RSAEnc(byte[] data, byte[] key) //RSA
        {
            var keyParser = new AsnKeyParser(key);
            var publicKey = keyParser.ParseRSAPublicKey();

            var csp = new CspParameters {
                ProviderType = 1, KeyNumber = 1
            };

            var rsa = new RSACryptoServiceProvider(csp)
            {
                PersistKeyInCsp = false
            };

            rsa.ImportParameters(publicKey);
            byte[] enc = rsa.Encrypt(data, false);
            rsa.Clear();
            return(enc);
        }