public static void BasicEncryptionDecryptionTests()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");

            string enc = pc.encrypt("Pubnub Messaging API 1");
            Console.WriteLine ("Pubnub Messaging API 1 = " + enc);
            Console.WriteLine ("dec = " + pc.decrypt(enc));

            enc = pc.encrypt("yay!");
            Console.WriteLine ("yay = " + enc);
            Console.WriteLine ("dec = " + pc.decrypt(enc));

            Console.WriteLine ("Wi24KS4pcTzvyuGOHubiXg==: = " + pc.decrypt("Wi24KS4pcTzvyuGOHubiXg=="));
            Console.WriteLine ("f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=: = " + pc.decrypt("f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54="));
            Console.WriteLine ("f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=: = " + pc.decrypt("f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0="));
            Console.WriteLine ("zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF = " + pc.decrypt("zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF"));
            Console.WriteLine ("GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g= = " + pc.decrypt("GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g="));

            Console.WriteLine ("IDjZE9BHSjcX67RddfCYYg== = " + pc.decrypt("IDjZE9BHSjcX67RddfCYYg=="));
            Console.WriteLine ("Ns4TB41JjT2NCXaGLWSPAQ== = " + pc.decrypt("Ns4TB41JjT2NCXaGLWSPAQ=="));

            Console.WriteLine ("+BY5/miAA8aeuhVl4d13Kg== = " + pc.decrypt("+BY5/miAA8aeuhVl4d13Kg=="));

            Console.WriteLine ("Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE= = " + pc.decrypt("Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE="));
            Console.WriteLine ("q/xJqqN6qbiZMXYmiQC1Fw==: = " + pc.decrypt("q/xJqqN6qbiZMXYmiQC1Fw=="));
        }
示例#2
0
        public static void BasicEncryptionDecryptionTests()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");

            string enc = pc.encrypt("Pubnub Messaging API 1");

            Console.WriteLine("Pubnub Messaging API 1 = " + enc);
            Console.WriteLine("dec = " + pc.decrypt(enc));

            enc = pc.encrypt("yay!");
            Console.WriteLine("yay = " + enc);
            Console.WriteLine("dec = " + pc.decrypt(enc));

            Console.WriteLine("Wi24KS4pcTzvyuGOHubiXg==: = " + pc.decrypt("Wi24KS4pcTzvyuGOHubiXg=="));
            Console.WriteLine("f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=: = " + pc.decrypt("f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54="));
            Console.WriteLine("f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=: = " + pc.decrypt("f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0="));
            Console.WriteLine("zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF = " + pc.decrypt("zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF"));
            Console.WriteLine("GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g= = " + pc.decrypt("GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g="));

            Console.WriteLine("IDjZE9BHSjcX67RddfCYYg== = " + pc.decrypt("IDjZE9BHSjcX67RddfCYYg=="));
            Console.WriteLine("Ns4TB41JjT2NCXaGLWSPAQ== = " + pc.decrypt("Ns4TB41JjT2NCXaGLWSPAQ=="));

            Console.WriteLine("+BY5/miAA8aeuhVl4d13Kg== = " + pc.decrypt("+BY5/miAA8aeuhVl4d13Kg=="));

            Console.WriteLine("Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE= = " + pc.decrypt("Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE="));
            Console.WriteLine("q/xJqqN6qbiZMXYmiQC1Fw==: = " + pc.decrypt("q/xJqqN6qbiZMXYmiQC1Fw=="));
        }
示例#3
0
        public void TestNullEncryption()
        {

            bool isExpectedException = false;

            ThreadPool.QueueUserWorkItem((s) =>
                {
                    PubnubCrypto pc = new PubnubCrypto("enigma");
                    //serialized string
                    string strMessage = null;

                    try
                    {
                        //encrypt
                        string enc = pc.encrypt(strMessage);
                    }
                    catch (ArgumentNullException ane)
                    {
                        isExpectedException = true;
                    }

                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                        {
                            Assert.IsTrue(isExpectedException);
                            TestComplete();
                        });
                    
                });
        }
示例#4
0
 public void TestNullEncryption()
 {
     PubnubCrypto pc = new PubnubCrypto("enigma");
     //serialized string
     string strMessage = null;
     
     //encrypt
     string enc = pc.encrypt(strMessage);
 }
示例#5
0
        public void TestNullEncryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //serialized string
            string strMessage = null;

            //encrypt
            string enc = pc.encrypt(strMessage);
        }
示例#6
0
        public void TestYayEncryptionBasic ()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //deserialized string
            string strMessage= "yay!";
            //pubnub.publish(channel, strMessage, Common.DisplayReturnMessage);
            //Encrypt
            string enc = pc.encrypt(strMessage);
			Assert.True(("q/xJqqN6qbiZMXYmiQC1Fw==").Equals(enc));
        }
示例#7
0
        public void TestHashEncryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //serialized string
            string strMessage = "{\"foo\":{\"bar\":\"foobar\"}}";
            //encrypt
            string enc = pc.encrypt(strMessage);

            Assert.AreEqual("GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g=", enc);
        }
示例#8
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);
        }
示例#9
0
        public void TestStuffCanEncryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //input serialized string
            string strMessage = "{\"this stuff\":{\"can get\":\"complicated!\"}}";
            //encrypt
            string enc = pc.encrypt(strMessage);

            Assert.AreEqual("zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF", enc);
        }
示例#10
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);
        }
示例#11
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);
        }
示例#12
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);
        }
示例#13
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);
        }
示例#14
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);
        }
示例#15
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);
        }
示例#16
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);
        }
示例#17
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);
        }
示例#18
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);
        }
示例#19
0
        /**
         * Publish
         *
         * Send a message to a channel
         *
         * @param String channel name.
         * @param List<object> info.
         * @return bool false on fail
         */
        public bool publish(string channel, object message)
        {
            if (this.PUBLISH_KEY.Length == 0)
            {
                return(false);
            }
            // Generate String to Sign
            string signature = "0";

            if (this.SECRET_KEY.Length > 0)
            {
                StringBuilder string_to_sign = new StringBuilder();
                string_to_sign
                .Append(this.PUBLISH_KEY)
                .Append('/')
                .Append(this.SUBSCRIBE_KEY)
                .Append('/')
                .Append(this.SECRET_KEY)
                .Append('/')
                .Append(channel)
                .Append('/')
                .Append(SerializeToJsonString(message));     // 1
                ;
                // Sign Message
                signature = md5(string_to_sign.ToString());
            }
            string message_org = message.ToString();

            if (this.CIPHER_KEY.Length > 0)
            {
                PubnubCrypto aes = new PubnubCrypto(this.CIPHER_KEY);
                message = aes.encrypt(message_org);
            }

            // Build URL
            List <string> url = new List <string>();

            url.Add("publish");
            url.Add(this.PUBLISH_KEY);
            url.Add(this.SUBSCRIBE_KEY);
            url.Add(signature);
            url.Add(channel);
            url.Add("0");
            url.Add(SerializeToJsonString(message));

            return(_request(url, ResponseType.Publish));
        }
示例#20
0
        public void TestYayEncryption ()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //deserialized string
            string strMessage= "yay!";
            //serialize the string
            //JavaScriptSerializer js = new JavaScriptSerializer();
            strMessage= JsonConvert.SerializeObject(strMessage);
            Console.WriteLine(strMessage);
            //Encrypt
            string enc = pc.encrypt(strMessage);
			Assert.True(("Wi24KS4pcTzvyuGOHubiXg==" ).Equals( enc));
            /*PubnubCrypto pc = new PubnubCrypto("enigma");
            string strMessage= "yay!";
            JavaScriptSerializer js = new JavaScriptSerializer();
            strMessage= js.Serialize(strMessage);
            string enc = pc.encrypt(strMessage);*/

            //Assert.AreEqual("q/xJqqN6qbiZMXYmiQC1Fw==", enc);
        }
示例#21
0
        public void TestUnicodeCharsEncryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            string strMessage = "漢語";

            strMessage = JsonConvert.SerializeObject(strMessage);
            Console.WriteLine(strMessage);
            string enc = pc.encrypt(strMessage);
            Console.WriteLine(enc);
            Assert.AreEqual("+BY5/miAA8aeuhVl4d13Kg==", enc);
        }
示例#22
0
        public void TestPubNubEncryption1()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //non serialized string
            string strMessage = "Pubnub Messaging API 1";
            //serialize
            strMessage = JsonConvert.SerializeObject(strMessage);
            //encrypt
            string enc = pc.encrypt(strMessage);

            Assert.AreEqual("f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=", enc);
        }
示例#23
0
        public void TestObjectEncryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //create an object
            Object obj = new Object();
            //serialize
            string strObj = JsonConvert.SerializeObject(obj);
            //encrypt
            string enc = pc.encrypt(strObj);

            Assert.AreEqual("IDjZE9BHSjcX67RddfCYYg==", enc);
        }
示例#24
0
        public void TestPubNubEncryption1 ()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //non serialized string
            string strMessage= "Pubnub Messaging API 1";
            //pubnub.publish(channel, strMessage, Common.DisplayReturnMessage);
            //serialize
            //JavaScriptSerializer js = new JavaScriptSerializer();
            strMessage= JsonConvert.SerializeObject(strMessage);
            //encrypt
            string enc = pc.encrypt(strMessage);

			Assert.True(("f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=").Equals(enc));
        }
示例#25
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);
        }
示例#26
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);
        }
示例#27
0
        public void TestStuffCanEncryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //input serialized string
            string strMessage = "{\"this stuff\":{\"can get\":\"complicated!\"}}";
            //encrypt
            string enc = pc.encrypt(strMessage);

            Assert.AreEqual("zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF", enc);
        }
示例#28
0
        public void TestMyObjectEncryption ()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //create an object of the custom class
            CustomClass cc = new CustomClass();
            //pubnub.publish(channel, cc, Common.DisplayReturnMessage);
            //serialize it
            //JavaScriptSerializer js = new JavaScriptSerializer();
            string res = JsonConvert.SerializeObject(cc);
            //encrypt it
            string enc = pc.encrypt(res);

			Assert.True(("Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=").Equals(enc));
        }
示例#29
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);
 }
示例#30
0
        public void TestHashEncryption ()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //serialized string
            string strMessage= "{\"foo\":{\"bar\":\"foobar\"}}";
            //pubnub.publish(channel, strMessage, Common.DisplayReturnMessage);
            //encrypt
            string enc = pc.encrypt(strMessage);

			Assert.True(("GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g=").Equals(enc));
        }
示例#31
0
        public void TestStuffCanEncryption ()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //input serialized string
            string strMessage= "{\"this stuff\":{\"can get\":\"complicated!\"}}";
            //pubnub.publish(channel, strMessage, Common.DisplayReturnMessage);
            //encrypt
            string enc = pc.encrypt(strMessage);

			Assert.True(("zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF").Equals(enc));
        }
示例#32
0
        public void TestGermanCharsEncryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            string strMessage = "ÜÖ";

            strMessage = JsonConvert.SerializeObject(strMessage);
            Console.WriteLine(strMessage);
            string enc = pc.encrypt(strMessage);
            Console.WriteLine(enc);
            Assert.AreEqual("stpgsG1DZZxb44J7mFNSzg==", enc);
        }
示例#33
0
        public void TestHashEncryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //serialized string
            string strMessage = "{\"foo\":{\"bar\":\"foobar\"}}";
            //encrypt
            string enc = pc.encrypt(strMessage);

            Assert.AreEqual("GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g=", enc);
        }
示例#34
0
文件: Pubnub.cs 项目: Vlanta/c-sharp
        /**
         * Publish
         * 
         * Send a message to a channel
         * 
         * @param String channel name.
         * @param List<object> info.
         * @return bool false on fail
         */
        public bool publish(string channel, object message)
        {
            if (this.PUBLISH_KEY.Length == 0) return false;
            // Generate String to Sign
            string signature = "0";
            if (this.SECRET_KEY.Length > 0)
            {
                StringBuilder string_to_sign = new StringBuilder();
                string_to_sign
                    .Append(this.PUBLISH_KEY)
                    .Append('/')
                    .Append(this.SUBSCRIBE_KEY)
                    .Append('/')
                    .Append(this.SECRET_KEY)
                    .Append('/')
                    .Append(channel)
                    .Append('/')
                    .Append(SerializeToJsonString(message)); // 1
                ;
                // Sign Message
                signature = md5(string_to_sign.ToString());
            }
            string message_org = message.ToString();
            if (this.CIPHER_KEY.Length > 0)
            {
                PubnubCrypto aes = new PubnubCrypto(this.CIPHER_KEY);
                message = aes.encrypt(message_org);
            }

            // Build URL
            List<string> url = new List<string>();
            url.Add("publish");
            url.Add(this.PUBLISH_KEY);
            url.Add(this.SUBSCRIBE_KEY);
            url.Add(signature);
            url.Add(channel);
            url.Add("0");
            url.Add(SerializeToJsonString(message));

            return _request(url, ResponseType.Publish);
        }
示例#35
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);
        }
示例#36
0
        public void TestArrayEncryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //create an empty array object
            object[] objArr = { };
            //serialize
            string strArr = JsonConvert.SerializeObject(objArr);
            //Encrypt
            string enc = pc.encrypt(strArr);

            Assert.AreEqual("Ns4TB41JjT2NCXaGLWSPAQ==", enc);
        }
示例#37
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);
        }
示例#38
0
        public void TestPubNubEncryption2 ()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //Deserialized
            string strMessage= "Pubnub Messaging API 2";
            //pubnub.publish(channel, strMessage, Common.DisplayReturnMessage);
            //serialize the message
            //JavaScriptSerializer js = new JavaScriptSerializer();
            strMessage= JsonConvert.SerializeObject(strMessage);
            //encrypt
            string enc = pc.encrypt(strMessage);

			Assert.True(("f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=").Equals(enc));
        }
示例#39
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);
        }
示例#40
0
        public void TestGermanCharsEncryption ()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            string strMessage= "ÜÖ";
            //pubnub.publish(channel, strMessage, Common.DisplayReturnMessage);

            //JavaScriptSerializer js = new JavaScriptSerializer();
            strMessage= JsonConvert.SerializeObject(strMessage);
            Console.WriteLine(strMessage);
            string enc = pc.encrypt(strMessage);
            Console.WriteLine(enc);
			Assert.True(("stpgsG1DZZxb44J7mFNSzg==").Equals(enc));
        }
示例#41
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);
 }
示例#42
0
        public void TestNullEncryption ()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //serialized string
            string strMessage= null;
            //encrypt
            string enc = pc.encrypt(strMessage);

			Assert.True(("").Equals(enc));
        }
示例#43
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);
        }
示例#44
0
        public void TestUnicodeCharsEncryption ()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            string strMessage= "漢語";
            //pubnub.publish(channel, strMessage, Common.DisplayReturnMessage);

            //JavaScriptSerializer js = new JavaScriptSerializer();
            strMessage= JsonConvert.SerializeObject(strMessage);
            Console.WriteLine(strMessage);
            string enc = pc.encrypt(strMessage);
            Console.WriteLine(enc);
			Assert.True(("+BY5/miAA8aeuhVl4d13Kg==").Equals(enc));
        }