public byte[] Encrypt(byte[] rgb, bool fOAEP) { // choose between OAEP or PKCS#1 v.1.5 padding AsymmetricKeyExchangeFormatter fmt = null; if (fOAEP) { fmt = new RSAOAEPKeyExchangeFormatter(rsa); } else { fmt = new RSAPKCS1KeyExchangeFormatter(rsa); } return(fmt.CreateKeyExchange(rgb)); }