byte[] key = Encoding.ASCII.GetBytes("MySecretKey"); ICipherParameters parameters = new KeyParameter(key); var aesCipher = CipherUtilities.GetCipher("AES/CBC/PKCS7Padding"); aesCipher.Init(true, parameters);
var rsaCipher = CipherUtilities.GetCipher("RSA/NONE/NoPadding"); var rsaParams = new ParametersWithRandom( new RsaKeyParameters(false, n, e), new SecureRandom()); rsaCipher.Init(true, rsaParams);In both examples, we use ICipherParameters to initialize the key and other required parameters for the cipher algorithm. This interface is a part of Bouncy Castle cryptography library for C#.