public void Initialise()
        {
            _encryptionProvider = Aes.Create();

            var ivMock = new Mock <IIV>();

            ivMock.Setup(m => m.GenerateIV(It.IsAny <int>())).Returns(TestConstants.IvData);

            _iv            = ivMock.Object;
            _key           = Mock.Of <IKey>();
            _fileEncryptor = new FileEncryptor(new Key("password"), _iv, _encryptionProvider);
        }
        public StreamEncryptor(IKey key, IIV iv, SymmetricAlgorithm encryptionProvider)
        {
            if (key == null)
                throw new ArgumentNullException(nameof(key));
            if (encryptionProvider == null)
                throw new ArgumentNullException(nameof(encryptionProvider));
            if (iv == null)
                throw new ArgumentNullException(nameof(iv));

            _key = key;
            _iv = iv;
            _encryptionProvider = encryptionProvider;
        }
        public void Initialise()
        {
            _encryptionProvider = Aes.Create();

            var ivMock = new Mock <IIV>();

            ivMock.Setup(m => m.GenerateIV(It.IsAny <int>())).Returns(TestConstants.IvData);

            _iv              = ivMock.Object;
            _key             = Mock.Of <IKey>();
            _streamEncryptor = new StreamEncryptor(new Key("password"), _iv, _encryptionProvider);
            _unencryptedFile = Mock.Of <IFile>(m => m.Read() == GetUnencryptedTestStream());
            _encryptedFile   = Mock.Of <IFile>(m => m.Read() == GetEncryptedTestStream());
        }
Exemple #4
0
        public StreamEncryptor(IKey key, IIV iv, SymmetricAlgorithm encryptionProvider)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }
            if (encryptionProvider == null)
            {
                throw new ArgumentNullException(nameof(encryptionProvider));
            }
            if (iv == null)
            {
                throw new ArgumentNullException(nameof(iv));
            }

            _key = key;
            _iv  = iv;
            _encryptionProvider = encryptionProvider;
        }
 public FileEncryptor(IKey key, IIV iv, SymmetricAlgorithm encryptionProvider)
     : base(key, iv, encryptionProvider)
 {
 }
Exemple #6
0
 public FileEncryptor(IKey key, IIV iv, SymmetricAlgorithm encryptionProvider)
     : base(key, iv, encryptionProvider)
 {
 }
        public void Initialise()
        {
            _encryptionProvider = Aes.Create();

            var ivMock = new Mock<IIV>();
            ivMock.Setup(m => m.GenerateIV(It.IsAny<int>())).Returns(TestConstants.IvData);

            _iv = ivMock.Object;
            _key = Mock.Of<IKey>();
            _streamEncryptor = new StreamEncryptor(new Key("password"), _iv, _encryptionProvider);
            _unencryptedFile = Mock.Of<IFile>(m => m.Read() == GetUnencryptedTestStream());
            _encryptedFile = Mock.Of<IFile>(m => m.Read() == GetEncryptedTestStream());
        }