public void Salsa20Test() { var key = StreamEncryption.GenerateKey(); var nonce = StreamEncryption.GenerateNonceSalsa20(); string message = "Hello, World!"; var cipherText = StreamEncryption.EncryptSalsa20(message, nonce, key); var decrypted = StreamEncryption.DecryptSalsa20(cipherText, nonce, key); Assert.AreEqual(message, System.Text.Encoding.UTF8.GetString(decrypted)); byte[] byteMessage = System.Text.Encoding.UTF8.GetBytes(message); cipherText = StreamEncryption.EncryptSalsa20(byteMessage, nonce, key); decrypted = StreamEncryption.EncryptSalsa20(cipherText, nonce, key); Assert.AreEqual(Convert.ToBase64String(byteMessage), Convert.ToBase64String(decrypted)); }
public void GenerateNonceSalsa20Test() { Assert.AreEqual(8, StreamEncryption.GenerateNonceSalsa20().Length); }