public void CryptoSign_Should_Success() { //Arrange String message = "test"; Byte[] bMessage = Encoding.UTF8.GetBytes(message); Byte[] ssk = new Byte[TweetNaCl.SignSecretKeyBytes]; Byte[] sMessage; //Act var spk = TweetNaCl.CryptoSignKeypair(ssk); sMessage = TweetNaCl.CryptoSign(bMessage, ssk); //Assert Assert.AreEqual(Encoding.ASCII.GetString(sMessage).Length, bMessage.Length + TweetNaCl.SignBytes, "Message sign failed."); }
public void CryptoSignOpen_Should_Success() { //Arrange String message = "test"; Byte[] bMessage = Encoding.UTF8.GetBytes(message); Byte[] ssk = new Byte[TweetNaCl.SignSecretKeyBytes]; Byte[] sMessage = new Byte[TweetNaCl.SignBytes + bMessage.Length]; Byte[] cMessage = new Byte[bMessage.Length]; var spk = TweetNaCl.CryptoSignKeypair(ssk); sMessage = TweetNaCl.CryptoSign(bMessage, ssk); //Act cMessage = TweetNaCl.CryptoSignOpen(sMessage, spk); Assert.AreEqual(cMessage.Length, bMessage.Length, "Message sign verification failed."); Assert.AreEqual(Encoding.UTF8.GetString(cMessage), message, "Messages sign verification failed."); }