//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; }
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); }