Example #1
0
        public void TestObjectDecryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            ////Deserialized
            string message = "IDjZE9BHSjcX67RddfCYYg==";
            ////Decrypt
            string decryptedMessage = pc.Decrypt(message);
            ////create an object
            Object obj = new Object();
            ////Serialize the object
            string result = JsonConvert.SerializeObject(obj);

            Assert.AreEqual(result, decryptedMessage);
        }
Example #2
0
        public void TestObjectDecryptionJSONFx()
        {
            PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
            //Deserialized
            string message = "IDjZE9BHSjcX67RddfCYYg==";
            //Decrypt
            string decrypted = pubnubCrypto.Decrypt(message);
            //create an object
            Object obj = new Object();
            //Serialize the object
            string result = Common.SerializeUsingJSONFx(obj);

            Assert.AreEqual(decrypted, result);
        }
Example #3
0
        public void TestMyObjectDecryptionJSONFx()
        {
            PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
            //Deserialized
            string message = "Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=";
            //Decrypt
            string decrypted = pubnubCrypto.Decrypt(message);
            //create an object of the custom class
            CustomClass cc = new CustomClass();
            //Serialize it
            string result = Common.SerializeUsingJSONFx(cc);

            Assert.AreEqual(decrypted, result);
        }
Example #4
0
        public void TestGermanCharsDecryption()
        {
            Debug.Log("Running TestGermanCharsDecryption()");
            PubnubCrypto pc      = new PubnubCrypto("enigma");
            string       message = "stpgsG1DZZxb44J7mFNSzg==";

            //decrypt
            string decryptedMessage = pc.Decrypt(message);

            //deserialize
            message = (decryptedMessage != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject <string>(decryptedMessage) : "";

            UUnitAssert.Equals("ÜÖ", message);
        }
Example #5
0
        public void TestUnicodeCharsDecryption()
        {
            Debug.Log("Running TestUnicodeCharsDecryption()");
            PubnubCrypto pc      = new PubnubCrypto("enigma");
            string       message = "+BY5/miAA8aeuhVl4d13Kg==";
            //decrypt
            string decryptedMessage = pc.Decrypt(message);

            //deserialize
            //message = (decryptedMessage != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject<string>(decryptedMessage) : "";
            message = (decryptedMessage != "**DECRYPT ERROR**") ? (string)(new JsonFXDotNet().DeserializeToObject(decryptedMessage)) : "";

            UUnitAssert.Equals("漢語", message);
        }
Example #6
0
        public void TestPubNubDecryption1()
        {
            Debug.Log("Running TestPubNubDecryption1()");
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //deserialized string
            string message = "f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=";
            //decrypt
            string decryptedMessage = pc.Decrypt(message);

            //deserialize
            //message = (decryptedMessage != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject<string>(decryptedMessage) : "";
            message = (decryptedMessage != "**DECRYPT ERROR**") ? (string)(new JsonFXDotNet().DeserializeToObject(decryptedMessage)) : "";
            UUnitAssert.Equals("Pubnub Messaging API 1", message);
        }
Example #7
0
        public void TestMyObjectDecryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            ////Deserialized
            string message = "Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=";
            ////Decrypt
            string decryptedMessage = pc.Decrypt(message);
            ////create an object of the custom class
            CustomClass cc = new CustomClass();
            ////Serialize it
            string result = JsonConvert.SerializeObject(cc);

            Assert.AreEqual(result, decryptedMessage);
        }
Example #8
0
        //will fail with minijson
        //[Test]
        public void TestObjectDecryptionMiniJson()
        {
            pn = EditorCommon.InitPN(pnConfig);
            PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma", PNLog);
            //Deserialized
            string message = "IDjZE9BHSjcX67RddfCYYg==";
            //Decrypt
            string decrypted = pubnubCrypto.Decrypt(message);
            //create an object
            Object obj = new Object();
            //Serialize the object
            string result = Common.SerializeMiniJson(obj);

            Assert.True((decrypted).Equals(result));
        }
Example #9
0
        public void TestMyObjectDecryption()
        {
            Debug.Log("Running TestMyObjectDecryption()");
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //Deserialized
            string message = "Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=";
            //Decrypt
            string decryptedMessage = pc.Decrypt(message);
            //create an object of the custom class
            CustomClass cc = new CustomClass();
            //Serialize it
            string result = new JsonFXDotNet().SerializeToJsonString(cc); //JsonConvert.SerializeObject(cc);

            UUnitAssert.Equals(result, decryptedMessage);
        }
Example #10
0
        public void TestYayDecryption()
        {
            PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
            //Non deserialized string
            string message = "\"Wi24KS4pcTzvyuGOHubiXg==\"";

            //Deserialize
            message = JsonConvert.DeserializeObject <string>(message);
            //decrypt
            string decrypted = pubnubCrypto.Decrypt(message);

            //deserialize again
            message = JsonConvert.DeserializeObject <string>(decrypted);
            Assert.True(("yay!").Equals(message));
        }
Example #11
0
        public void TestArrayDecryptionUsingMiniJson()
        {
            PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
            //Input the deserialized string
            string message = "Ns4TB41JjT2NCXaGLWSPAQ==";
            //decrypt
            string decrypted = pubnubCrypto.Decrypt(message);

            //create a serialized object
            object[] objArr = { };
            string   result = Common.SerializeMiniJson(objArr);

            //compare the serialized object and the return of the Decrypt method
            Assert.True((result).Equals(decrypted));
        }
Example #12
0
        public void TestArrayDecryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //Input the deserialized string
            string message = "Ns4TB41JjT2NCXaGLWSPAQ==";
            //Decrypt
            string decryptedMessage = pc.Decrypt(message);

            //create a serialized object
            object[] emptyArrayObject = { };
            string   result           = JsonConvert.SerializeObject(emptyArrayObject);

            //compare the serialized object and the return of the Decrypt method
            Assert.AreEqual(result, decryptedMessage);
        }
Example #13
0
        //[Test]
        public void TestMoonImageDecryption()
        {
            PNConfiguration config = new PNConfiguration {
                UseRandomInitializationVector = true
            };
            PubnubCrypto pc        = new PubnubCrypto("enigma", config, null, null);
            string       base64str = "TOAFyhNC/hcs8Hr0/A1KPf9HFXZe10sIs5GN5IL6CmB1Li+4xo00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ToCharArray(), 0, base64str.Length);

            byte[] decryptedBytes = pc.Decrypt(messageBytes, true);
            System.IO.File.WriteAllBytes(@"C:\Pandu\temp\file_dec_364234.png", decryptedBytes);
            byte[] expectedBytes = new byte[] { 121, 97, 121, 33 };
            Assert.AreEqual(expectedBytes, decryptedBytes);
        }
Example #14
0
 public void TestStuffcanDecryption()
 {
     ThreadPool.QueueUserWorkItem((s) =>
     {
         PubnubCrypto pc = new PubnubCrypto("enigma");
         //deserialized string
         string message = "zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF";
         //Decrypt
         string decryptedMessage = pc.Decrypt(message);
         Deployment.Current.Dispatcher.BeginInvoke(() =>
         {
             Assert.AreEqual("{\"this stuff\":{\"can get\":\"complicated!\"}}", decryptedMessage);
             TestComplete();
         });
     });
 }
Example #15
0
 public void TestYayDecryptionBasic()
 {
     ThreadPool.QueueUserWorkItem((s) =>
     {
         PubnubCrypto pc = new PubnubCrypto("enigma");
         string message  = "q/xJqqN6qbiZMXYmiQC1Fw==";
         //Decrypt
         string decryptedMessage = pc.Decrypt(message);
         //deserialize again
         Deployment.Current.Dispatcher.BeginInvoke(() =>
         {
             Assert.AreEqual("yay!", decryptedMessage);
             TestComplete();
         });
     });
 }
Example #16
0
        public void TestObjectDecryption()
        {
            Debug.Log("Running TestObjectDecryption()");
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //Deserialized
            string message = "IDjZE9BHSjcX67RddfCYYg==";
            //Decrypt
            string decryptedMessage = pc.Decrypt(message);

            //create an object
            System.Object obj = new System.Object();
            //Serialize the object
            string result = JsonConvert.SerializeObject(obj);

            UUnitAssert.Equals(result, decryptedMessage);
        }
Example #17
0
        public void TestYayDecryptionJSONFx()
        {
            PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
            //Non deserialized string
            string message = "\"Wi24KS4pcTzvyuGOHubiXg==\"";

            //Deserialize
            message = Common.DeserializeUsingJSONFx <string>(message);

            //decrypt
            string decrypted = pubnubCrypto.Decrypt(message);

            //deserialize again
            message = Common.DeserializeUsingJSONFx <string>(decrypted);
            Assert.AreEqual("yay!", message);
        }
Example #18
0
        //[ExpectedException (typeof(ArgumentNullException))]
        public void TestNullDecryption()
        {
            pn = EditorCommon.InitPN(pnConfig);
            PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma", PNLog);
            //deserialized string
            string message = null;
            //decrypt
            var ex = Assert.Throws <ArgumentNullException>(() => pubnubCrypto.Decrypt(message));

            /* #if UNITY_2019_1_OR_NEWER */
            Assert.That(ex.Message.Contains("Value cannot be null."), ex.Message, null);

            /* #else
            *  Assert.That(ex.Message.Contains("Argument cannot be null."),ex.Message, null);
            #endif*/
        }
Example #19
0
        public void TestObjectDecryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //Deserialized
            string message = "IDjZE9BHSjcX67RddfCYYg==";
            //Decrypt
            string decryptedMessage = pc.Decrypt(message);
            //create an object
            Object obj = new Object();
            //Serialize the object
            string result = JsonConvert.SerializeObject(obj);

            int same = string.Compare(result, decryptedMessage, StringComparison.InvariantCulture);

            Assert.IsTrue(same == 0);
        }
Example #20
0
        public void TestArrayDecryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //Input the deserialized string
            string message = "Ns4TB41JjT2NCXaGLWSPAQ==";
            //decrypt
            string decryptedMessage = pc.Decrypt(message);

            //create a serialized object
            object[] emptyArrayObject = { };
            string   result           = JsonConvert.SerializeObject(emptyArrayObject);
            int      same             = String.Compare(result, decryptedMessage, StringComparison.InvariantCulture);

            //compare the serialized object and the return of the Decrypt method
            Assert.IsTrue(same == 0);
        }
Example #21
0
        public void TestArrayDecryption()
        {
            Debug.Log("Running TestArrayDecryption()");
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //Input the deserialized string
            string message = "Ns4TB41JjT2NCXaGLWSPAQ==";
            //decrypt
            string decryptedMessage = pc.Decrypt(message);

            //create a serialized object
            object[] emptyArrayObject = { };
            string   result           = new JsonFXDotNet().SerializeToJsonString(emptyArrayObject); //JsonConvert.SerializeObject(emptyArrayObject);

            //compare the serialized object and the return of the Decrypt method
            UUnitAssert.Equals(result, decryptedMessage);
        }
Example #22
0
 public void TestHashDecryption()
 {
     ThreadPool.QueueUserWorkItem((s) =>
     {
         PubnubCrypto pc = new PubnubCrypto("enigma");
         //deserialized string
         string message = "GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g=";
         //Decrypt
         string decryptedMessage = pc.Decrypt(message);
         Deployment.Current.Dispatcher.BeginInvoke(() =>
         {
             Assert.AreEqual("{\"foo\":{\"bar\":\"foobar\"}}", decryptedMessage);
             TestComplete();
         });
     });
 }
Example #23
0
        //will fail with minijson
        //[Test]
        public void TestMyObjectDecryptionMiniJson()
        {
            PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
            //Deserialized
            string message = "Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=";
            //Decrypt
            string decrypted = pubnubCrypto.Decrypt(message);
            //create an object of the custom class
            CustomClass cc = new CustomClass();
            //Serialize it
            string result = Common.SerializeMiniJson(cc);

            UnityEngine.Debug.Log("decrypted:" + decrypted);
            UnityEngine.Debug.Log("result:" + result);
            Assert.True((decrypted).Equals(result));
        }
Example #24
0
        public void TestYayDecryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //string strMessage= "\"q/xJqqN6qbiZMXYmiQC1Fw==\"";
            //Non deserialized string
            string message = "\"Wi24KS4pcTzvyuGOHubiXg==\"";

            //Deserialize
            message = JsonConvert.DeserializeObject <string>(message);
            //Decrypt
            string decryptedMessage = pc.Decrypt(message);

            //deserialize again
            message = JsonConvert.DeserializeObject <string>(decryptedMessage);
            Assert.AreEqual("yay!", message);
        }
Example #25
0
        public void TestMyObjectDecryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //Deserialized
            string message = "Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=";
            //Decrypt
            string decryptedMessage = pc.Decrypt(message);
            //create an object of the custom class
            CustomClass cc = new CustomClass();
            //Serialize it
            string result = JsonConvert.SerializeObject(cc);

            int same = string.Compare(result, decryptedMessage, StringComparison.InvariantCulture);

            Assert.IsTrue(same == 0);
        }
Example #26
0
        public void TestYayDecryption()
        {
            Debug.Log("Running TestYayDecryption()");
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //string strMessage= "\"q/xJqqN6qbiZMXYmiQC1Fw==\"";
            //Non deserialized string
            string message = "\"Wi24KS4pcTzvyuGOHubiXg==\"";

            //Deserialize
            message = new JsonFXDotNet().DeserializeToObject(message) as string; //JsonConvert.DeserializeObject<string>(message);
            //decrypt
            string decryptedMessage = pc.Decrypt(message);

            //deserialize again
            message = new JsonFXDotNet().DeserializeToObject(decryptedMessage) as string;  //JsonConvert.DeserializeObject<string>(decryptedMessage);
            UUnitAssert.Equals("yay!", message);
        }
Example #27
0
        public void TestYayDecryptionMiniJson()
        {
            pn = EditorCommon.InitPN(pnConfig);
            PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma", PNLog);
            //Non deserialized string
            string message = "\"Wi24KS4pcTzvyuGOHubiXg==\"";

            //Deserialize
            message = Common.DeserializeMiniJson <string> (message);

            //decrypt
            string decrypted = pubnubCrypto.Decrypt(message);

            //deserialize again
            message = Common.DeserializeMiniJson <string> (decrypted);
            Assert.True(("yay!").Equals(message));
        }
Example #28
0
 public void TestGermanCharsDecryption()
 {
     ThreadPool.QueueUserWorkItem((s) =>
     {
         PubnubCrypto pc = new PubnubCrypto("enigma");
         string message  = "stpgsG1DZZxb44J7mFNSzg==";
         //Decrypt
         string decryptedMessage = pc.Decrypt(message);
         //deserialize
         message = (decryptedMessage != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject <string>(decryptedMessage) : "";
         Deployment.Current.Dispatcher.BeginInvoke(() =>
         {
             Assert.AreEqual("ÜÖ", message);
             TestComplete();
         });
     });
 }
Example #29
0
 public void TestPubNubDecryption1()
 {
     ThreadPool.QueueUserWorkItem((s) =>
     {
         PubnubCrypto pc = new PubnubCrypto("enigma");
         //deserialized string
         string message = "f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=";
         //Decrypt
         string decryptedMessage = pc.Decrypt(message);
         //deserialize
         message = (decryptedMessage != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject <string>(decryptedMessage) : "";
         Deployment.Current.Dispatcher.BeginInvoke(() =>
         {
             Assert.AreEqual("Pubnub Messaging API 1", message);
             TestComplete();
         });
     });
 }
Example #30
0
 public void TestUnicodeCharsDecryption()
 {
     ThreadPool.QueueUserWorkItem((s) =>
     {
         PubnubCrypto pc = new PubnubCrypto("enigma");
         string message  = "+BY5/miAA8aeuhVl4d13Kg==";
         //JavaScriptSerializer js = new JavaScriptSerializer();
         //Decrypt
         string decryptedMessage = pc.Decrypt(message);
         //deserialize
         message = (decryptedMessage != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject <string>(decryptedMessage) : "";
         Deployment.Current.Dispatcher.BeginInvoke(() =>
         {
             Assert.AreEqual("漢語", message);
             TestComplete();
         });
     });
 }