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);
        }
示例#2
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 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());
        }
示例#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;
        }
示例#5
0
 public FileEncryptor(IKey key, IIV iv, SymmetricAlgorithm encryptionProvider)
     : base(key, iv, encryptionProvider)
 {
 }
示例#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());
        }