コード例 #1
0
        public void BytesSyncTest(string path)
        {
            var          data    = File.ReadAllBytes(path);
            ICryptoGraph crypto  = new CryptographAes();
            var          iv      = crypto.GenerateIv();
            var          actual  = crypto.Encrypt(data, iv, key);
            var          decrypt = crypto.Decrypt(actual, iv, key);

            decrypt.Should().BeEquivalentTo(data);
        }
コード例 #2
0
        public void StringSyncTest(string path)
        {
            var          text    = File.ReadAllText(path);
            ICryptoGraph crypto  = new CryptographAes();
            var          iv      = crypto.GenerateIv();
            var          actual  = crypto.Encrypt(text, iv, key);
            var          decrypt = crypto.Decrypt(actual, iv, key);

            decrypt.Should().Be(text);
        }
コード例 #3
0
        public void BytesSyncTest(string path, string expected)
        {
            var          data   = File.ReadAllBytes(path);
            ICryptoGraph crypto = new CryptographAes();
            var          actual = crypto.Encrypt(data, iv, key);

            actual.Should().BeEquivalentTo(File.ReadAllBytes(expected));
            var decrypt = crypto.Decrypt(actual, iv, key);

            decrypt.Should().BeEquivalentTo(data);
        }