示例#1
0
        public void Encryption_Verify_With_Server()
        {
            long nonceValue   = 256 * 256 * 256 + 1;
            var  signedBase64 =
                "uEfMMnTDZOlvAMh6Hw38mVfvDJr7jkG4nVOLqiIuXrAmkse7awC5cbHVczLW4jOmzlsO3VX5ZpoFTV5lLhbeCHsibmFtZSI6InRlcmVuY2UiLCJjb21wYW55IjoibWFkaGVhZCIsImFkZHJlc3MiOiJzY2llbmNlcGFyayJ9";
            var encryptedBase64 =
                "vRVKqppXx+txj38ZjhfS83C39O3fzRpb3rk/vG8KMEuU28RNesE/QdG18L5UHFXv7fpbA3y1A5aQ55qeWt4=";
            var singed    = Convert.FromBase64String(signedBase64);
            var encrypted = Convert.FromBase64String(encryptedBase64);

            var message = new TestMessage()
            {
                name = "terence", company = "madhead", address = "sciencepark"
            };
            var decrypted = _encryptionHelper.Decrypt(encrypted, nonceValue);
            var opened    = _encryptionHelper.SignOpenMessage(singed);

            Assert.AreEqual(JsonUtility.ToJson(message), Encoding.UTF8.GetString(decrypted));
            Assert.AreEqual(JsonUtility.ToJson(message), Encoding.UTF8.GetString(opened));
        }