コード例 #1
0
        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;
        }
コード例 #3
0
        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)
 {
 }
コード例 #7
0
        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());
        }