示例#1
0
        public void EncryptStringToBytes_ShoulThrowExcpetion_When_KeyIsNull()
        {
            var rijandeal = new RijndealCryptography();
            var IV        = rijandeal.GenerateIV();

            Assert.Throws <KeyException>(
                () =>
                rijandeal.EncryptStringToBytes("test", null, IV)
                );
        }
示例#2
0
        public void DecryptStringFromBytes_ShoulThrowExcpetion_When_KeyIsNull()
        {
            var rijandeal = new RijndealCryptography();
            var IV        = rijandeal.GenerateIV();

            Assert.Throws <KeyException>(
                () =>
                rijandeal.DecryptStringFromBytes(new byte[] { 0, 1 }, null, IV)
                );
        }
示例#3
0
        public void EncryptStringToBytes_ShouldReturn_EncryptedValue(string value)
        {
            var rijandeal = new RijndealCryptography();
            var IV        = rijandeal.GenerateIV();
            var KEY       = rijandeal.GenerateKey();
            var encrypted = rijandeal.EncryptStringToBytes(value, KEY, IV);
            var decrypted = rijandeal.DecryptStringFromBytes(encrypted, KEY, IV);

            Assert.Equal(value, decrypted);
        }
示例#4
0
        public void DecryptStringFromBytes_ShoulThrowExcpetion_When_textIsnull()
        {
            var rijandeal = new RijndealCryptography();
            var KEY       = rijandeal.GenerateKey();
            var IV        = rijandeal.GenerateIV();

            Assert.Throws <RijndealException>(
                () =>
                rijandeal.DecryptStringFromBytes(null, KEY, IV)
                );
        }