コード例 #1
0
        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.");
        }