public void Setup() { _data = Encoding.UTF8.GetBytes("Quod Erat Dimanstrandum"); _password = Encoding.UTF8.GetBytes( "If you immediately know the dimalight is fire, then the security was cooked a long time ago."); var bitConverter = new FastBitConverter(); var keyGenerator = new KeyGenerator(bitConverter); var blockManipulator = new BlockManipulator(); _tea = new BlackTeaCryptoServiceProvider(blockManipulator, keyGenerator, bitConverter); _cipher = _tea.EncryptRaw(_data, _password); }
public void TestEncryptDecrypt() { var bitConverter = new FastBitConverter(); var keyGenerator = new KeyGenerator(bitConverter); var blockManipulator = new BlockManipulator(); var tea = new BlackTeaCryptoServiceProvider(blockManipulator, keyGenerator, bitConverter); var password = Encoding.UTF8.GetBytes("Quod Erat Dimanstrandum"); var data = Encoding.UTF8.GetBytes( "If you immediately know the dimalight is fire, then the security was cooked a long time ago."); var cipher = tea.EncryptRaw(data, password); var plain = tea.DecryptRaw(cipher, password); Assert.IsTrue(plain.SequenceEqual(data)); }
public void TestDeterministicOutput() { var bitConverter = new FastBitConverter(); var keyGenerator = new KeyGenerator(bitConverter); var blockManipulator = new BlockManipulator(); var tea = new BlackTeaCryptoServiceProvider(blockManipulator, keyGenerator, bitConverter); var passwordBytes = new byte[16]; var dataBytes = new byte[16]; for (var i = 0; i < 10000; i++) { Guid.NewGuid().TryWriteBytes(passwordBytes); Guid.NewGuid().TryWriteBytes(dataBytes); var cipher = tea.EncryptRaw(dataBytes, passwordBytes); var plain = tea.DecryptRaw(cipher, passwordBytes); Assert.IsTrue(plain.SequenceEqual(dataBytes)); } }
public void Encrypt() { _tea.EncryptRaw(_data, _password); }