Example #1
0
 public void TestYayDecryptionBasic()
 {
     PubnubCrypto pc = new PubnubCrypto("enigma");
     string strMessage = "q/xJqqN6qbiZMXYmiQC1Fw==";
     //decrypt
     string dec = pc.decrypt(strMessage);
     //deserialize again
     Assert.AreEqual("yay!", dec);
 }
Example #2
0
        public void TestNullEncryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //serialized string
            string strMessage = null;

            //encrypt
            string enc = pc.encrypt(strMessage);
        }
Example #3
0
        public void TestNullDecryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //deserialized string
            string strMessage = null;
            //decrypt
            string dec = pc.decrypt(strMessage);

            Assert.AreEqual("", dec);
        }
Example #4
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 #5
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 #6
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 #7
0
        public void TestArrayDecryptionUsingMiniJson()
        {
            pn = EditorCommon.InitPN(pnConfig);
            PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma", PNLog);
            //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 #8
0
        public void TestYayDecryption()
        {
            PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma");
            //Non deserialized string
            string message = "\"Wi24KS4pcTzvyuGOHubiXg==\"";

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

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

            //deserialize again
            message = Common.Deserialize <string> (decrypted);
            Assert.True(("yay!").Equals(message));
        }
Example #9
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 #10
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           = JsonConvert.SerializeObject(emptyArrayObject);

            //compare the serialized object and the return of the Decrypt method
            UUnitAssert.Equals(result, decryptedMessage);
        }
Example #11
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 #12
0
 public void TestYayEncryptionBasic()
 {
     ThreadPool.QueueUserWorkItem((s) =>
     {
         PubnubCrypto pc = new PubnubCrypto("enigma");
         //deserialized string
         string message = "yay!";
         //Encrypt
         string encryptedMessage = pc.Encrypt(message);
         Deployment.Current.Dispatcher.BeginInvoke(() =>
         {
             Assert.AreEqual("q/xJqqN6qbiZMXYmiQC1Fw==", encryptedMessage);
             TestComplete();
         });
     });
 }
Example #13
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 #14
0
 public void TestHashEncryption()
 {
     ThreadPool.QueueUserWorkItem((s) =>
     {
         PubnubCrypto pc = new PubnubCrypto("enigma");
         //serialized string
         string message = "{\"foo\":{\"bar\":\"foobar\"}}";
         //Encrypt
         string encryptedMessage = pc.Encrypt(message);
         Deployment.Current.Dispatcher.BeginInvoke(() =>
         {
             Assert.AreEqual("GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g=", encryptedMessage);
             TestComplete();
         });
     });
 }
Example #15
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 #16
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.True("yay!" == message);
        }
Example #17
0
        public void TestArrayDecryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //Input the deserialized string
            string strMessage = "Ns4TB41JjT2NCXaGLWSPAQ==";
            //decrypt
            string dec = pc.decrypt(strMessage);

            //create a serialized object
            object []            objArr = {};
            JavaScriptSerializer js     = new JavaScriptSerializer();
            string res = js.Serialize(objArr);

            //compare the serialized object and the return of the Decrypt method
            Assert.AreEqual(res, dec);
        }
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 TestYayDecryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //string strMessage= "\"q/xJqqN6qbiZMXYmiQC1Fw==\"";
            //Non deserialized string
            string strMessage = "\"Wi24KS4pcTzvyuGOHubiXg==\"";

            //Deserialize
            //JavaScriptSerializer js = new JavaScriptSerializer();
            strMessage = JsonConvert.DeserializeObject <string>(strMessage);
            //decrypt
            string dec = pc.decrypt(strMessage);

            //deserialize again
            strMessage = JsonConvert.DeserializeObject <string>(dec);
            Assert.True(("yay!").Equals(strMessage));
        }
Example #20
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 #21
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 = JsonConvert.DeserializeObject <string>(message);
            //decrypt
            string decryptedMessage = pc.Decrypt(message);

            //deserialize again
            message = JsonConvert.DeserializeObject <string>(decryptedMessage);
            UUnitAssert.Equals("yay!", message);
        }
Example #22
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 #23
0
        public void TestYayDecryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //string strMessage= "\"q/xJqqN6qbiZMXYmiQC1Fw==\"";
            //Non deserialized string
            string strMessage = "\"Wi24KS4pcTzvyuGOHubiXg==\"";
            //Deserialize
            JavaScriptSerializer js = new JavaScriptSerializer();

            strMessage = js.Deserialize <string>(strMessage);
            //decrypt
            string dec = pc.decrypt(strMessage);

            //deserialize again
            strMessage = js.Deserialize <string>(dec);
            Assert.AreEqual("yay!", strMessage);
        }
Example #24
0
        public void TestGermanCharsEncryption()
        {
            ThreadPool.QueueUserWorkItem((s) =>
            {
                PubnubCrypto pc = new PubnubCrypto("enigma");
                string message  = "ÜÖ";

                message = JsonConvert.SerializeObject(message);
                Console.WriteLine(message);
                string encryptedMessage = pc.Encrypt(message);
                Console.WriteLine(encryptedMessage);
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    Assert.AreEqual("stpgsG1DZZxb44J7mFNSzg==", encryptedMessage);
                    TestComplete();
                });
            });
        }
Example #25
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 #26
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();
         });
     });
 }
Example #27
0
 public void TestPubNubDecryption2()
 {
     ThreadPool.QueueUserWorkItem((s) =>
     {
         PubnubCrypto pc = new PubnubCrypto("enigma");
         //Deserialized string
         string message = "f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=";
         //Decrypt
         string decryptedMessage = pc.Decrypt(message);
         //Deserialize
         message = JsonConvert.DeserializeObject <string>(decryptedMessage);
         Deployment.Current.Dispatcher.BeginInvoke(() =>
         {
             Assert.AreEqual("Pubnub Messaging API 2", message);
             TestComplete();
         });
     });
 }
Example #28
0
        public void TestUnicodeCharsEncryption()
        {
            ThreadPool.QueueUserWorkItem((s) =>
            {
                PubnubCrypto pc = new PubnubCrypto("enigma");
                string message  = "漢語";

                message = JsonConvert.SerializeObject(message);
                Console.WriteLine(message);
                string encryptedMessage = pc.Encrypt(message);
                Console.WriteLine(encryptedMessage);
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    Assert.AreEqual("+BY5/miAA8aeuhVl4d13Kg==", encryptedMessage);
                    TestComplete();
                });
            });
        }
Example #29
0
 public void TestObjectEncryption()
 {
     ThreadPool.QueueUserWorkItem((s) =>
     {
         PubnubCrypto pc = new PubnubCrypto("enigma");
         //create an object
         Object obj = new Object();
         //serialize
         string serializedObject = JsonConvert.SerializeObject(obj);
         //Encrypt
         string encryptedMessage = pc.Encrypt(serializedObject);
         Deployment.Current.Dispatcher.BeginInvoke(() =>
         {
             Assert.AreEqual("IDjZE9BHSjcX67RddfCYYg==", encryptedMessage);
             TestComplete();
         });
     });
 }
Example #30
0
 public void TestPubNubEncryption1()
 {
     ThreadPool.QueueUserWorkItem((s) =>
     {
         PubnubCrypto pc = new PubnubCrypto("enigma");
         //non serialized string
         string message = "Pubnub Messaging API 1";
         //serialize
         message = JsonConvert.SerializeObject(message);
         //Encrypt
         string encryptedMessage = pc.Encrypt(message);
         Deployment.Current.Dispatcher.BeginInvoke(() =>
         {
             Assert.AreEqual("f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=", encryptedMessage);
             TestComplete();
         });
     });
 }
Example #31
0
 public void TestArrayEncryption()
 {
     ThreadPool.QueueUserWorkItem((s) =>
     {
         PubnubCrypto pc = new PubnubCrypto("enigma");
         //create an empty array object
         object[] emptyArray = { };
         //serialize
         string serializedArray = JsonConvert.SerializeObject(emptyArray);
         //Encrypt
         string encryptedMessage = pc.Encrypt(serializedArray);
         Deployment.Current.Dispatcher.BeginInvoke(() =>
         {
             Assert.AreEqual("Ns4TB41JjT2NCXaGLWSPAQ==", encryptedMessage);
             TestComplete();
         });
     });
 }
Example #32
0
        public void TestYayEncryptionBasicWithDynamicIV()
        {
            IPubnubUnitTest pubnubUnitTest = new PubnubUnitTest();

            pubnubUnitTest.IV = new byte[16] {
                49, 50, 51, 52, 53, 54, 55, 56, 57, 48, 49, 50, 51, 52, 53, 54
            };
            PNConfiguration config = new PNConfiguration {
                UseRandomInitializationVector = true
            };
            PubnubCrypto pc = new PubnubCrypto("enigma", config, null, pubnubUnitTest);
            ////deserialized string
            string message = "yay!";
            ////Encrypt
            string encryptedMessage = pc.Encrypt(message);

            Assert.AreEqual("MTIzNDU2Nzg5MDEyMzQ1NjdnONoCgo0wbuMGGMmfMX0=", encryptedMessage);
        }
Example #33
0
        public void TestMyObjectEncryption()
        {
            ThreadPool.QueueUserWorkItem((s) =>
            {
                PubnubCrypto pc = new PubnubCrypto("enigma");
                //create an object of the custom class
                CustomClass cc = new CustomClass();
                //serialize it
                string result = JsonConvert.SerializeObject(cc);

                //Encrypt it
                string encryptedMessage = pc.Encrypt(result);
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    Assert.AreEqual("Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=", encryptedMessage);
                    TestComplete();
                });
            });
        }
Example #34
0
        public void TestObjectEncryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //create an object
            Object obj = new Object();
            //serialize
            JavaScriptSerializer js = new JavaScriptSerializer();
            string strObj = js.Serialize(obj);
            //encrypt
            string enc = pc.encrypt(strObj);

            Assert.AreEqual("IDjZE9BHSjcX67RddfCYYg==", enc);
        }
Example #35
0
        public void TestObjectDecryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //Deserialized
            string strMessage = "IDjZE9BHSjcX67RddfCYYg==";
            //Decrypt
            string dec = pc.decrypt(strMessage);
            //create an object
            Object obj = new Object();
            //Serialize the object
            JavaScriptSerializer js = new JavaScriptSerializer();
            string res = js.Serialize(obj);

            Assert.AreEqual(res, dec);
        }
Example #36
0
        public void TestGermanCharsEncryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            string strMessage = "ÜÖ";

            JavaScriptSerializer js = new JavaScriptSerializer();
            strMessage = js.Serialize(strMessage);
            Console.WriteLine(strMessage);
            string enc = pc.encrypt(strMessage);
            Console.WriteLine(enc);
            Assert.AreEqual("stpgsG1DZZxb44J7mFNSzg==", enc);
        }
Example #37
0
        public void TestArrayEncryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //create an empty array object
            object[] objArr = { };
            //serialize
            JavaScriptSerializer js = new JavaScriptSerializer();
            string strArr = js.Serialize(objArr);
            //Encrypt
            string enc = pc.encrypt(strArr);

            Assert.AreEqual("Ns4TB41JjT2NCXaGLWSPAQ==", enc);
        }
Example #38
0
        public void TestGermanCharsDecryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            string strMessage = "stpgsG1DZZxb44J7mFNSzg==";
            JavaScriptSerializer js = new JavaScriptSerializer();
            //decrypt
            string dec = pc.decrypt(strMessage);
            //deserialize
            strMessage = js.Deserialize<string>(dec);

            Assert.AreEqual("ÜÖ", strMessage);
        }
Example #39
0
        public void TestPubNubEncryption1()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //non serialized string
            string strMessage = "Pubnub Messaging API 1";
            //serialize
            JavaScriptSerializer js = new JavaScriptSerializer();
            strMessage = js.Serialize(strMessage);
            //encrypt
            string enc = pc.encrypt(strMessage);

            Assert.AreEqual("f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=", enc);
        }
Example #40
0
 public void TestPubNubDecryption1()
 {
     PubnubCrypto pc = new PubnubCrypto("enigma");
     //deserialized string
     string strMessage = "f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=";
     JavaScriptSerializer js = new JavaScriptSerializer();
     //decrypt
     string dec = pc.decrypt(strMessage);
     //deserialize
     strMessage = js.Deserialize<string>(dec);
     Assert.AreEqual("Pubnub Messaging API 1", strMessage);
 }
Example #41
0
        public void TestStuffcanDecryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //deserialized string
            string strMessage = "zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF";
            //decrypt
            string dec = pc.decrypt(strMessage);

            Assert.AreEqual("{\"this stuff\":{\"can get\":\"complicated!\"}}", dec);
        }
Example #42
0
        public void TestHashDecryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //deserialized string
            string strMessage = "GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g=";
            //decrypt
            string dec = pc.decrypt(strMessage);

            Assert.AreEqual("{\"foo\":{\"bar\":\"foobar\"}}", dec);
        }
Example #43
0
        public void TestUnicodeCharsEncryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            string strMessage = "漢語";

            JavaScriptSerializer js = new JavaScriptSerializer();
            strMessage = js.Serialize(strMessage);
            Console.WriteLine(strMessage);
            string enc = pc.encrypt(strMessage);
            Console.WriteLine(enc);
            Assert.AreEqual("+BY5/miAA8aeuhVl4d13Kg==", enc);
        }
Example #44
0
        public void TestUnicodeCharsDecryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            string strMessage = "+BY5/miAA8aeuhVl4d13Kg==";
            JavaScriptSerializer js = new JavaScriptSerializer();
            //decrypt
            string dec = pc.decrypt(strMessage);
            //deserialize
            strMessage = js.Deserialize<string>(dec);

            Assert.AreEqual("漢語", strMessage);
        }
Example #45
0
 public void TestPubNubDecryption2()
 {
     PubnubCrypto pc = new PubnubCrypto("enigma");
     //Deserialized string    
     string strMessage = "f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=";
     //Decrypt
     string dec = pc.decrypt(strMessage);
     //Deserialize
     JavaScriptSerializer js = new JavaScriptSerializer();
     strMessage = js.Deserialize<string>(dec);
     Assert.AreEqual("Pubnub Messaging API 2", strMessage);
 }
Example #46
0
 public void TestYayEncryption()
 {
     PubnubCrypto pc = new PubnubCrypto("enigma");
     //deserialized string
     string strMessage = "yay!";
     //serialize the string
     JavaScriptSerializer js = new JavaScriptSerializer();
     strMessage = js.Serialize(strMessage);
     Console.WriteLine(strMessage);
     //Encrypt
     string enc = pc.encrypt(strMessage);
     Assert.AreEqual("Wi24KS4pcTzvyuGOHubiXg==", enc);
 }
Example #47
0
 public void TestArrayDecryption()
 {
     PubnubCrypto pc = new PubnubCrypto("enigma");
     //Input the deserialized string
     string strMessage = "Ns4TB41JjT2NCXaGLWSPAQ==";
     //decrypt
     string dec = pc.decrypt(strMessage);
     //create a serialized object
     object[] objArr = { };
     JavaScriptSerializer js = new JavaScriptSerializer();
     string res = js.Serialize(objArr);
     //compare the serialized object and the return of the Decrypt method
     Assert.AreEqual(res, dec);
 }
Example #48
0
        public void TestPubNubEncryption2()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //Deserialized
            string strMessage = "Pubnub Messaging API 2";
            //serialize the message
            JavaScriptSerializer js = new JavaScriptSerializer();
            strMessage = js.Serialize(strMessage);
            //encrypt
            string enc = pc.encrypt(strMessage);

            Assert.AreEqual("f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=", enc);
        }
Example #49
0
        public void TestMyObjectDecryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //Deserialized
            string strMessage = "Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=";
            //Decrypt
            string dec = pc.decrypt(strMessage);
            //create an object of the custom class
            CustomClass cc = new CustomClass();

            JavaScriptSerializer js = new JavaScriptSerializer();
            //Serialize it
            string res = js.Serialize(cc);

            Assert.AreEqual(res, dec);
        }
Example #50
0
        public void TestMyObjectEncryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //create an object of the custom class
            CustomClass cc = new CustomClass();
            //serialize it
            JavaScriptSerializer js = new JavaScriptSerializer();
            string res = js.Serialize(cc);
            //encrypt it
            string enc = pc.encrypt(res);

            Assert.AreEqual("Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=", enc);
        }
Example #51
0
 public void TestYayDecryption()
 {
     PubnubCrypto pc = new PubnubCrypto("enigma");
     //string strMessage= "\"q/xJqqN6qbiZMXYmiQC1Fw==\"";
     //Non deserialized string
     string strMessage = "\"Wi24KS4pcTzvyuGOHubiXg==\"";
     //Deserialize 
     JavaScriptSerializer js = new JavaScriptSerializer();
     strMessage = js.Deserialize<string>(strMessage);
     //decrypt
     string dec = pc.decrypt(strMessage);
     //deserialize again
     strMessage = js.Deserialize<string>(dec);
     Assert.AreEqual("yay!", strMessage);
 }
Example #52
0
 public void TestYayEncryptionBasic()
 {
     PubnubCrypto pc = new PubnubCrypto("enigma");
     //deserialized string
     string strMessage = "yay!";
     //Encrypt
     string enc = pc.encrypt(strMessage);
     Assert.AreEqual("q/xJqqN6qbiZMXYmiQC1Fw==", enc);
 }