protected sealed override void Dispose(bool disposing) { if (disposing) { _cipher?.Dispose(); _cipher = null !; } base.Dispose(disposing); }
// // The first parameter is a delegate that instantiates a CngKey rather than a CngKey itself. That's because CngKeys are stateful objects // and concurrent encryptions on the same CngKey will corrupt each other. // // The delegate must instantiate a new CngKey, based on a new underlying NCryptKeyHandle, each time is called. // public BasicSymmetricCipherNCrypt(Func <CngKey> cngKeyFactory, CipherMode cipherMode, int blockSizeInBytes, byte[]?iv, bool encrypting, int paddingSizeInBytes) : base(iv, blockSizeInBytes, paddingSizeInBytes) { _cipher = new BasicSymmetricCipherLiteNCrypt(cngKeyFactory, cipherMode, blockSizeInBytes, iv, encrypting, paddingSizeInBytes); }