rinseoff/tests/TestDecrypt.cs

33 lines
805 B
C#
Raw Normal View History

2020-12-19 06:25:49 +00:00
using NUnit.Framework;
using System.Text;
using System.Collections.Generic;
2020-12-20 09:41:14 +00:00
using Sodium;
2020-12-19 06:25:49 +00:00
using rinseoff;
namespace testDecrypted
{
public class Tests
{
[SetUp]
public void Setup()
{
}
[Test]
public void testDecrypted()
{
2020-12-20 09:41:14 +00:00
var key = Sodium.SecretBox.GenerateKey();
var nonce = Sodium.SecretBox.GenerateNonce();
var msg = Encoding.Default.GetBytes("hey");
var encrypted = Sodium.SecretBox.Create(msg, nonce, key);
var combined = new List<byte>();
combined.AddRange(nonce);
combined.AddRange(encrypted);
2020-12-19 06:25:49 +00:00
2020-12-20 09:41:14 +00:00
Assert.AreEqual(
RinseOff.decrypt_secret_bytes(combined.ToArray(), key),
msg
);
2020-12-19 06:25:49 +00:00
}
}
}