public void TestNullDecryption() { bool isExpectedException = false; string dec = ""; ThreadPool.QueueUserWorkItem((s) => { PubnubCrypto pc = new PubnubCrypto("enigma"); //deserialized string string strMessage = null; try { //decrypt dec = pc.decrypt(strMessage); } catch (ArgumentNullException ane) { isExpectedException = true; } Deployment.Current.Dispatcher.BeginInvoke(() => { //Assert.AreEqual("", dec); Assert.IsTrue(isExpectedException); TestComplete(); }); }); }
public void TestYayDecryptionBasic() { PubnubCrypto pc = new PubnubCrypto("enigma"); string strMessage = "q/xJqqN6qbiZMXYmiQC1Fw=="; //decrypt string dec = pc.decrypt(strMessage); //deserialize again Assert.AreEqual("yay!", dec); }
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); }
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); }
public void TestNullDecryption() { PubnubCrypto pc = new PubnubCrypto("enigma"); //deserialized string string strMessage = null; //decrypt string dec = pc.decrypt(strMessage); Assert.AreEqual("", dec); }
public void TestYayDecryptionBasic() { PubnubCrypto pc = new PubnubCrypto("enigma"); string strMessage = "q/xJqqN6qbiZMXYmiQC1Fw=="; //decrypt string dec = pc.decrypt(strMessage); //deserialize again Assert.AreEqual("yay!", dec); }
public void TestNullDecryption() { PubnubCrypto pc = new PubnubCrypto("enigma"); //deserialized string string strMessage = null; //decrypt string dec = pc.decrypt(strMessage); Assert.AreEqual("", dec); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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)); }
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); }
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); }
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); }
public void TestGermanCharsDecryption() { PubnubCrypto pc = new PubnubCrypto("enigma"); string strMessage = "stpgsG1DZZxb44J7mFNSzg=="; //decrypt string dec = pc.decrypt(strMessage); //deserialize strMessage = (dec != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject<string>(dec) : ""; Assert.AreEqual("ÜÖ", strMessage); }
public void TestUnicodeCharsDecryption() { PubnubCrypto pc = new PubnubCrypto("enigma"); string strMessage = "+BY5/miAA8aeuhVl4d13Kg=="; //decrypt string dec = pc.decrypt(strMessage); //deserialize strMessage = (dec != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject<string>(dec) : ""; Assert.AreEqual("漢語", strMessage); }
public void TestPubNubDecryption1() { PubnubCrypto pc = new PubnubCrypto("enigma"); //deserialized string string strMessage = "f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0="; //decrypt string dec = pc.decrypt(strMessage); //deserialize strMessage = (dec != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject<string>(dec) : ""; Assert.AreEqual("Pubnub Messaging API 1", strMessage); }
public void TestPubNubDecryption2() { PubnubCrypto pc = new PubnubCrypto("enigma"); //Deserialized string string strMessage = "f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54="; //Decrypt string dec = pc.decrypt(strMessage); //Deserialize strMessage = JsonConvert.DeserializeObject<string>(dec); Assert.AreEqual("Pubnub Messaging API 2", strMessage); }
public void TestHashDecryption() { ThreadPool.QueueUserWorkItem((s) => { PubnubCrypto pc = new PubnubCrypto("enigma"); //deserialized string string strMessage = "GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g="; //decrypt string dec = pc.decrypt(strMessage); Deployment.Current.Dispatcher.BeginInvoke(() => { Assert.AreEqual("{\"foo\":{\"bar\":\"foobar\"}}", dec); TestComplete(); }); }); }
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); }
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); }
public void TestGermanCharsDecryption() { PubnubCrypto pc = new PubnubCrypto("enigma"); string strMessage= "stpgsG1DZZxb44J7mFNSzg=="; //JavaScriptSerializer js = new JavaScriptSerializer(); //decrypt string dec = pc.decrypt(strMessage); //deserialize strMessage= JsonConvert.DeserializeObject<string>(dec); Assert.True(("ÜÖ").Equals(strMessage)); }
public void TestUnicodeCharsDecryption() { PubnubCrypto pc = new PubnubCrypto("enigma"); string strMessage= "+BY5/miAA8aeuhVl4d13Kg=="; //JavaScriptSerializer js = new JavaScriptSerializer(); //decrypt string dec = pc.decrypt(strMessage); //deserialize strMessage= JsonConvert.DeserializeObject<string>(dec); Assert.True(("漢語").Equals(strMessage)); }
public void TestObjectDecryption() { ThreadPool.QueueUserWorkItem((s) => { 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); string res = JsonConvert.SerializeObject(obj); Deployment.Current.Dispatcher.BeginInvoke(() => { Assert.AreEqual(res, dec); TestComplete(); }); }); }
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); }
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); }
public void TestStuffcanDecryption() { ThreadPool.QueueUserWorkItem((s) => { PubnubCrypto pc = new PubnubCrypto("enigma"); //deserialized string string strMessage = "zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF"; //decrypt string dec = pc.decrypt(strMessage); Deployment.Current.Dispatcher.BeginInvoke(() => { Assert.AreEqual("{\"this stuff\":{\"can get\":\"complicated!\"}}", dec); TestComplete(); }); }); }
public void TestPubNubDecryption1() { ThreadPool.QueueUserWorkItem((s) => { 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); //strMessage = JsonConvert.DeserializeObject<string>(dec); strMessage = (dec != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject<string>(dec) : ""; Deployment.Current.Dispatcher.BeginInvoke(() => { Assert.AreEqual("Pubnub Messaging API 1", strMessage); TestComplete(); }); }); }
public void TestPubNubDecryption2() { ThreadPool.QueueUserWorkItem((s) => { PubnubCrypto pc = new PubnubCrypto("enigma"); //Deserialized string string strMessage = "f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54="; //Decrypt string dec = pc.decrypt(strMessage); //Deserialize strMessage = JsonConvert.DeserializeObject<string>(dec); Deployment.Current.Dispatcher.BeginInvoke(() => { Assert.AreEqual("Pubnub Messaging API 2", strMessage); TestComplete(); }); }); }
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); }
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); }
/** * Http Get Request * * @param List<string> request of URL directories. * @return List<object> from JSON response. */ private bool _request(List <string> url_components, ResponseType type) { List <object> result = new List <object>(); StringBuilder url = new StringBuilder(); // Add Origin To The Request url.Append(this.ORIGIN); // Generate URL with UTF-8 Encoding foreach (string url_bit in url_components) { url.Append("/"); url.Append(_encodeURIcomponent(url_bit)); } if (type == ResponseType.Presence || type == ResponseType.Subscribe) { url.Append("?uuid="); url.Append(this.sessionUUID); } if (type == ResponseType.DetailedHistory) { url.Append(parameters); } // Temporary fail if string too long if (url.Length > this.LIMIT) { result.Add(0); result.Add("Message Too Long."); // return result; } Uri requestUri = new Uri(url.ToString()); // Force canonical path and query string paq = requestUri.PathAndQuery; FieldInfo flagsFieldInfo = typeof(Uri).GetField("m_Flags", BindingFlags.Instance | BindingFlags.NonPublic); ulong flags = (ulong)flagsFieldInfo.GetValue(requestUri); flags &= ~((ulong)0x30); // Flags.PathNotCanonical|Flags.QueryNotCanonical flagsFieldInfo.SetValue(requestUri, flags); // Create Request HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestUri); try { // Make request with the following inline Asynchronous callback IAsyncResult asyncResult = request.BeginGetResponse(new AsyncCallback((asynchronousResult) => { HttpWebRequest aRequest = (HttpWebRequest)asynchronousResult.AsyncState; HttpWebResponse aResponse = (HttpWebResponse)aRequest.EndGetResponse(asynchronousResult); using (StreamReader streamReader = new StreamReader(aResponse.GetResponseStream())) { // Deserialize the result string jsonString = streamReader.ReadToEnd(); result = DeserializeToListOfObject(jsonString); JavaScriptSerializer jS = new JavaScriptSerializer(); result = (List <object>)jS.Deserialize <List <object> >(jsonString); var resultOccupancy = jS.DeserializeObject(jsonString); if ((result.Count != 0) && (type != ResponseType.DetailedHistory)) { if (result[0] is object[]) { foreach (object message in (object[])result[0]) { this.ReturnMessage = message; } } } switch (type) { case ResponseType.Publish: result.Add(url_components[4]); Publish = result; break; case ResponseType.History: if (this.CIPHER_KEY.Length > 0) { List <object> historyDecrypted = new List <object>(); PubnubCrypto aes = new PubnubCrypto(this.CIPHER_KEY); foreach (object message in result) { historyDecrypted.Add(aes.decrypt(message.ToString())); } History = historyDecrypted; } else { History = result; } break; case ResponseType.DetailedHistory: if (this.CIPHER_KEY.Length > 0) { List <object> historyDecrypted = new List <object>(); PubnubCrypto aes = new PubnubCrypto(this.CIPHER_KEY); foreach (object message in (object[])result[0]) { historyDecrypted.Add(aes.decrypt(message.ToString())); } DetailedHistory = historyDecrypted; } else { DetailedHistory = (object[])(result[0]); } break; case ResponseType.Here_Now: Dictionary <string, object> dic = (Dictionary <string, object>)resultOccupancy; List <object> presented = new List <object>(); presented.Add(dic); Here_Now = (List <object>)presented; break; case ResponseType.Time: Time = result; break; case ResponseType.Subscribe: result.Add(url_components[2]); Subscribe = result; break; case ResponseType.Presence: result.Add(url_components[2]); Presence = result; break; default: break; } } }), request ); //asyncResult.AsyncWaitHandle.WaitOne(); return(true); } catch (System.Exception ex) { Console.WriteLine(ex.ToString()); return(false); } }
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); }
public void TestGermanCharsDecryption() { ThreadPool.QueueUserWorkItem((s) => { PubnubCrypto pc = new PubnubCrypto("enigma"); string strMessage = "stpgsG1DZZxb44J7mFNSzg=="; //JavaScriptSerializer js = new JavaScriptSerializer(); //decrypt string dec = pc.decrypt(strMessage); //deserialize //strMessage = js.Deserialize<string>(dec); strMessage = (dec != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject<string>(dec) : ""; Deployment.Current.Dispatcher.BeginInvoke(() => { Assert.AreEqual("ÜÖ", strMessage); TestComplete(); }); }); }
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 = JsonConvert.SerializeObject(obj); Assert.True(dec.Equals(res)); }
/** * Http Get Request * * @param List<string> request of URL directories. * @return List<object> from JSON response. */ private bool _request(List<string> url_components, ResponseType type) { List<object> result = new List<object>(); StringBuilder url = new StringBuilder(); // Add Origin To The Request url.Append(this.ORIGIN); // Generate URL with UTF-8 Encoding foreach (string url_bit in url_components) { url.Append("/"); url.Append(_encodeURIcomponent(url_bit)); } if (type == ResponseType.Presence || type == ResponseType.Subscribe) { url.Append("?uuid="); url.Append(this.sessionUUID); } if (type == ResponseType.DetailedHistory) url.Append(parameters); // Temporary fail if string too long if (url.Length > this.LIMIT) { result.Add(0); result.Add("Message Too Long."); // return result; } Uri requestUri = new Uri(url.ToString()); // Force canonical path and query string paq = requestUri.PathAndQuery; FieldInfo flagsFieldInfo = typeof(Uri).GetField("m_Flags", BindingFlags.Instance | BindingFlags.NonPublic); ulong flags = (ulong)flagsFieldInfo.GetValue(requestUri); flags &= ~((ulong)0x30); // Flags.PathNotCanonical|Flags.QueryNotCanonical flagsFieldInfo.SetValue(requestUri, flags); // Create Request HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestUri); try { // Make request with the following inline Asynchronous callback IAsyncResult asyncResult = request.BeginGetResponse(new AsyncCallback((asynchronousResult) => { HttpWebRequest aRequest = (HttpWebRequest)asynchronousResult.AsyncState; HttpWebResponse aResponse = (HttpWebResponse)aRequest.EndGetResponse(asynchronousResult); using (StreamReader streamReader = new StreamReader(aResponse.GetResponseStream())) { // Deserialize the result string jsonString = streamReader.ReadToEnd(); result = DeserializeToListOfObject(jsonString); JavaScriptSerializer jS = new JavaScriptSerializer(); result = (List<object>)jS.Deserialize<List<object>>(jsonString); var resultOccupancy = jS.DeserializeObject(jsonString); if ((result.Count != 0) && (type != ResponseType.DetailedHistory)) { if (result[0] is object[]) { foreach (object message in (object[])result[0]) { this.ReturnMessage = message; } } } switch (type) { case ResponseType.Publish: result.Add(url_components[4]); Publish = result; break; case ResponseType.History: if (this.CIPHER_KEY.Length > 0) { List<object> historyDecrypted = new List<object>(); PubnubCrypto aes = new PubnubCrypto(this.CIPHER_KEY); foreach (object message in result) { historyDecrypted.Add(aes.decrypt(message.ToString())); } History = historyDecrypted; } else { History = result; } break; case ResponseType.DetailedHistory: if (this.CIPHER_KEY.Length > 0) { List<object> historyDecrypted = new List<object>(); PubnubCrypto aes = new PubnubCrypto(this.CIPHER_KEY); foreach (object message in (object[])result[0]) { historyDecrypted.Add(aes.decrypt(message.ToString())); } DetailedHistory = historyDecrypted; } else { DetailedHistory = (object[])(result[0]); } break; case ResponseType.Here_Now: Dictionary<string, object> dic = (Dictionary<string, object>)resultOccupancy; List<object> presented = new List<object>(); presented.Add(dic); Here_Now = (List<object>)presented; break; case ResponseType.Time: Time = result; break; case ResponseType.Subscribe: result.Add(url_components[2]); Subscribe = result; break; case ResponseType.Presence: result.Add(url_components[2]); Presence = result; break; default: break; } } }), request ); //asyncResult.AsyncWaitHandle.WaitOne(); return true; } catch (System.Exception ex) { Console.WriteLine(ex.ToString()); return false; } }
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); }
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= JsonConvert.DeserializeObject<string>(dec); Assert.True(("Pubnub Messaging API 2").Equals(strMessage)); }
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= JsonConvert.DeserializeObject<string>(dec); Assert.True(("Pubnub Messaging API 1").Equals(strMessage)); }
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==")); }