Ejemplo n.º 1
0
        public void TestGermanCharsDecryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            string strMessage= "stpgsG1DZZxb44J7mFNSzg==";
            JavaScriptSerializer js = new JavaScriptSerializer();
            //decrypt
            string dec = pc.EncryptOrDecrypt(false, strMessage);
            //deserialize
            strMessage= js.Deserialize<string>(dec);

            Assert.AreEqual("ÜÖ", strMessage);
        }
Ejemplo n.º 2
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.EncryptOrDecrypt(true, strArr);

            Assert.AreEqual("Ns4TB41JjT2NCXaGLWSPAQ==", enc);
        }
Ejemplo n.º 3
0
 public void TestArrayDecryption()
 {
     PubnubCrypto pc = new PubnubCrypto("enigma");
     //Input the deserialized string
     string strMessage= "Ns4TB41JjT2NCXaGLWSPAQ==";
     //decrypt
     string dec = pc.EncryptOrDecrypt(false, 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);
 }
Ejemplo n.º 4
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.EncryptOrDecrypt(true, strMessage);

            Assert.AreEqual("f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=", enc);
        }
Ejemplo n.º 5
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.EncryptOrDecrypt(true, strMessage);

            Assert.AreEqual("f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=", enc);
        }
Ejemplo n.º 6
0
 public void TestPubNubDecryption2()
 {
     PubnubCrypto pc = new PubnubCrypto("enigma");
     //Deserialized string
     string strMessage= "f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=";
     //Decrypt
     string dec = pc.EncryptOrDecrypt(false, strMessage);
     //Deserialize
     JavaScriptSerializer js = new JavaScriptSerializer();
     strMessage= js.Deserialize<string>(dec);
     Assert.AreEqual("Pubnub Messaging API 2", strMessage);
 }
Ejemplo n.º 7
0
 public void TestYayEncryptionBasic()
 {
     PubnubCrypto pc = new PubnubCrypto("enigma");
     //deserialized string
     string strMessage= "yay!";
     //Encrypt
     string enc = pc.EncryptOrDecrypt(true, strMessage);
     Assert.AreEqual("q/xJqqN6qbiZMXYmiQC1Fw==", enc);
 }
Ejemplo n.º 8
0
 public void TestYayDecryptionBasic()
 {
     PubnubCrypto pc = new PubnubCrypto("enigma");
     string strMessage= "q/xJqqN6qbiZMXYmiQC1Fw==";
     //decrypt
     string dec = pc.EncryptOrDecrypt(false, strMessage);
     //deserialize again
     Assert.AreEqual("yay!", dec);
 }
Ejemplo n.º 9
0
        public void TestUnicodeCharsEncryption()
        {
            /*string unicodeString = "漢語";

            Console.WriteLine( unicodeString );

            string encoded = EncodeNonAsciiCharacters(unicodeString);
            Console.WriteLine( encoded );

            string decoded = DecodeEncodedNonAsciiCharacters( encoded );
            Console.WriteLine( decoded );*/

            PubnubCrypto pc = new PubnubCrypto("enigma");
            string strMessage= "漢語";

            JavaScriptSerializer js = new JavaScriptSerializer();
            strMessage= js.Serialize(strMessage);
            Console.WriteLine(strMessage);
            string enc = pc.EncryptOrDecrypt(true, strMessage);
            Console.WriteLine(enc);
            Assert.AreEqual("+BY5/miAA8aeuhVl4d13Kg==", enc);
        }
Ejemplo n.º 10
0
        public void TestNullDecryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //deserialized string
            string strMessage= null;
            //decrypt
            string dec = pc.EncryptOrDecrypt(false, strMessage);

            Assert.AreEqual("", dec);
        }
Ejemplo n.º 11
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.EncryptOrDecrypt(true, res);

            Assert.AreEqual("Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=", enc);
        }
Ejemplo n.º 12
0
        public void TestMyObjectDecryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //Deserialized
            string strMessage= "Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=";
            //Decrypt
            string dec = pc.EncryptOrDecrypt(false, 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);
        }
Ejemplo n.º 13
0
        public void TestHashEncryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //serialized string
            string strMessage= "{\"foo\":{\"bar\":\"foobar\"}}";
            //encrypt
            string enc = pc.EncryptOrDecrypt(true, strMessage);

            Assert.AreEqual("GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g=", enc);
        }
Ejemplo n.º 14
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.EncryptOrDecrypt(true, strMessage);
            Console.WriteLine(enc);
            Assert.AreEqual("stpgsG1DZZxb44J7mFNSzg==", enc);
        }
Ejemplo n.º 15
0
        public void TestStuffCanEncryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //input serialized string
            string strMessage= "{\"this stuff\":{\"can get\":\"complicated!\"}}";
            //encrypt
            string enc = pc.EncryptOrDecrypt(true, strMessage);

            Assert.AreEqual("zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF", enc);
        }
Ejemplo n.º 16
0
        public void TestUnicodeCharsDecryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            string strMessage= "+BY5/miAA8aeuhVl4d13Kg==";
            JavaScriptSerializer js = new JavaScriptSerializer();
            //decrypt
            string dec = pc.EncryptOrDecrypt(false, strMessage);
            //deserialize
            strMessage= js.Deserialize<string>(dec);

            Assert.AreEqual("漢語", strMessage);
        }
Ejemplo n.º 17
0
        public void TestNullEncryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //serialized string
            string strMessage= null;
            //encrypt
            string enc = pc.EncryptOrDecrypt(true, strMessage);

            Assert.AreEqual("", enc);
        }
Ejemplo n.º 18
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.EncryptOrDecrypt(false, strMessage);
     //deserialize again
     strMessage= js.Deserialize<string>(dec);
     Assert.AreEqual("yay!", strMessage);
 }
Ejemplo n.º 19
0
        public void TestObjectDecryption()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");
            //Deserialized
            string strMessage= "IDjZE9BHSjcX67RddfCYYg==";
            //Decrypt
            string dec = pc.EncryptOrDecrypt(false, strMessage);
            //create an object
            Object obj = new Object();
            //Serialize the object
            JavaScriptSerializer js = new JavaScriptSerializer();
            string res = js.Serialize(obj);

            Assert.AreEqual(res, dec);
        }
Ejemplo n.º 20
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.EncryptOrDecrypt(true, strMessage);
            Assert.AreEqual("Wi24KS4pcTzvyuGOHubiXg==", enc);
            /*PubnubCrypto pc = new PubnubCrypto("enigma");
            string strMessage= "yay!";
            JavaScriptSerializer js = new JavaScriptSerializer();
            strMessage= js.Serialize(strMessage);
            string enc = pc.EncryptOrDecrypt(true, strMessage);*/

            //Assert.AreEqual("q/xJqqN6qbiZMXYmiQC1Fw==", enc);
        }
Ejemplo n.º 21
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.EncryptOrDecrypt(true, strObj);

            Assert.AreEqual("IDjZE9BHSjcX67RddfCYYg==", enc);
        }
Ejemplo n.º 22
0
 public void TestPubNubDecryption1()
 {
     PubnubCrypto pc = new PubnubCrypto("enigma");
     //deserialized string
     string strMessage= "f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=";
     JavaScriptSerializer js = new JavaScriptSerializer();
     //decrypt
     string dec = pc.EncryptOrDecrypt(false, strMessage);
     //deserialize
     strMessage= js.Deserialize<string>(dec);
     Assert.AreEqual("Pubnub Messaging API 1", strMessage);
 }
Ejemplo n.º 23
0
        public static void BasicEncryptionDecryptionTests()
        {
            PubnubCrypto pc = new PubnubCrypto("enigma");

            string enc = pc.EncryptOrDecrypt(true, "Pubnub Messaging API 1");
            Console.WriteLine ("Pubnub Messaging API 1 = " + enc);
            Console.WriteLine ("dec = " + pc.EncryptOrDecrypt(false, enc));

            enc = pc.EncryptOrDecrypt(true, "yay!");
            Console.WriteLine ("yay = " + enc);
            Console.WriteLine ("dec = " + pc.EncryptOrDecrypt(false, enc));

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

            Console.WriteLine ("IDjZE9BHSjcX67RddfCYYg== = " + pc.EncryptOrDecrypt(false, "IDjZE9BHSjcX67RddfCYYg=="));
            Console.WriteLine ("Ns4TB41JjT2NCXaGLWSPAQ== = " + pc.EncryptOrDecrypt(false, "Ns4TB41JjT2NCXaGLWSPAQ=="));

            Console.WriteLine ("+BY5/miAA8aeuhVl4d13Kg== = " + pc.EncryptOrDecrypt(false, "+BY5/miAA8aeuhVl4d13Kg=="));

            Console.WriteLine ("Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE= = " + pc.EncryptOrDecrypt(false, "Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE="));
            Console.WriteLine ("q/xJqqN6qbiZMXYmiQC1Fw==: = " + pc.EncryptOrDecrypt(false, "q/xJqqN6qbiZMXYmiQC1Fw=="));
        }