public void TestNullDecryption() { bool isExpectedException = false; string decryptedMessage = ""; ThreadPool.QueueUserWorkItem((s) => { PubnubCrypto pc = new PubnubCrypto("enigma"); //deserialized string string message = null; try { //Decrypt decryptedMessage = pc.Decrypt(message); } catch (ArgumentNullException) { isExpectedException = true; } Deployment.Current.Dispatcher.BeginInvoke(() => { //Assert.AreEqual("", dec); Assert.IsTrue(isExpectedException); TestComplete(); }); }); }
public void TestYayDecryptionBasic () { PubnubCrypto pubnubCrypto = new PubnubCrypto ("enigma"); string message = "q/xJqqN6qbiZMXYmiQC1Fw=="; //decrypt string decrypted = pubnubCrypto.Decrypt (message); Assert.True (("yay!").Equals (decrypted)); }
public void TestYayDecryptionBasic() { PubnubCrypto pc = new PubnubCrypto("enigma"); string message = "q/xJqqN6qbiZMXYmiQC1Fw=="; //decrypt string decryptedMessage = pc.Decrypt(message); //deserialize again Assert.AreEqual("yay!", decryptedMessage); }
public void TestGermanCharsDecryption() { PubnubCrypto pc = new PubnubCrypto("enigma"); string message = "stpgsG1DZZxb44J7mFNSzg=="; //Decrypt string decryptedMessage = pc.Decrypt(message); //deserialize message = (decryptedMessage != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject<string>(decryptedMessage) : ""; Assert.AreEqual("ÜÖ", message); }
public void TestNullDecryption() { PubnubCrypto pc = new PubnubCrypto("enigma"); //deserialized string string message = null; //decrypt string decryptedMessage = pc.Decrypt(message); Assert.AreEqual("", decryptedMessage); }
public void TestArrayDecryption() { PubnubCrypto pc = new PubnubCrypto("enigma"); //Input the deserialized string string message = "Ns4TB41JjT2NCXaGLWSPAQ=="; //Decrypt string decryptedMessage = pc.Decrypt(message); //create a serialized object object[] emptyArrayObject = { }; string result = JsonConvert.SerializeObject(emptyArrayObject); //compare the serialized object and the return of the Decrypt method Assert.AreEqual(result, decryptedMessage); }
public void TestYayDecryption () { PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma"); //Non deserialized string string message= "\"Wi24KS4pcTzvyuGOHubiXg==\""; //Deserialize message= JsonConvert.DeserializeObject<string>(message); //decrypt string decrypted= pubnubCrypto.Decrypt(message); //deserialize again message= JsonConvert.DeserializeObject<string>(decrypted); Assert.AreEqual("yay!", message); }
public void TestYayDecryptionMiniJson () { PubnubCrypto pubnubCrypto = new PubnubCrypto ("enigma"); //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)); }
internal static object DecodeMessage(PubnubCrypto aes, object element, string[] channels, Action <PubnubClientError> errorCallback, IJsonPluggableLibrary jsonPluggableLibrary, PubnubErrorFilter.Level errorLevel) { string decryptMessage = ""; try { decryptMessage = aes.Decrypt(element.ToString()); } catch (Exception ex) { decryptMessage = "**DECRYPT ERROR**"; string multiChannel = string.Join(",", channels); PubnubCallbacks.CallErrorCallback <object> (ex, null, multiChannel, PubnubErrorCode.None, PubnubErrorSeverity.Critical, errorCallback, errorLevel); } object decodeMessage = (decryptMessage == "**DECRYPT ERROR**") ? decryptMessage : jsonPluggableLibrary.DeserializeToObject(decryptMessage); return(decodeMessage); }
public void TestNullDecryption() { bool isExpectedException = false; string decryptedMessage = ""; PubnubCrypto pc = new PubnubCrypto("enigma"); //deserialized string string message = null; try { //Decrypt decryptedMessage = pc.Decrypt(message); } catch (ArgumentNullException) { isExpectedException = true; } Assert.IsTrue(isExpectedException); }
public void TestArrayDecryption() { ThreadPool.QueueUserWorkItem((s) => { 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 Deployment.Current.Dispatcher.BeginInvoke(() => { Assert.AreEqual(result, decryptedMessage); TestComplete(); }); }); }
internal static List <object> AddMessageToList(string cipherKey, IJsonPluggableLibrary jsonPluggableLibrary, object[] messages, int messageIndex, string currentChannel, object[] messageList) { List <object> itemMessage = new List <object>(); if (currentChannel.Contains(Utility.PresenceChannelSuffix)) { itemMessage.Add(messageList[messageIndex]); } else { //decrypt the subscriber message if cipherkey is available if (cipherKey.Length > 0) { object decodeMessage; try { PubnubCrypto aes = new PubnubCrypto(cipherKey); string decryptMessage = aes.Decrypt(messageList[messageIndex].ToString()); decodeMessage = (decryptMessage == "**DECRYPT ERROR**") ? decryptMessage : jsonPluggableLibrary.DeserializeToObject(decryptMessage); } catch (Exception decryptEx) { decodeMessage = messageList[messageIndex].ToString(); #if (ENABLE_PUBNUB_LOGGING) LoggingMethod.WriteToLog(string.Format("DateTime {0}, decodeMessage Exception: {1}", DateTime.Now.ToString(), decryptEx.ToString()), LoggingMethod.LevelError); #endif } itemMessage.Add(decodeMessage); } else { itemMessage.Add(messageList[messageIndex]); } } itemMessage.Add(messages[1].ToString()); itemMessage.Add(currentChannel.Replace(Utility.PresenceChannelSuffix, "")); return(itemMessage); }
public void TestPubNubDecryption1MiniJson () { PubnubCrypto pubnubCrypto = new PubnubCrypto ("enigma"); //deserialized string string message = "f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0="; //decrypt string decrypted = pubnubCrypto.Decrypt (message); //deserialize message = Common.DeserializeMiniJson<string> (decrypted); Assert.True (("Pubnub Messaging API 1").Equals (message)); }
public void TestPubNubDecryption2MiniJson () { PubnubCrypto pubnubCrypto = new PubnubCrypto ("enigma"); //Deserialized string string message = "f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54="; //Decrypt string decrypted = pubnubCrypto.Decrypt (message); //Deserialize message = Common.DeserializeMiniJson<string> (decrypted); Assert.True (("Pubnub Messaging API 2").Equals (message)); }
//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)); }
//will fail with minijson //[Test] public void TestObjectDecryptionMiniJson () { PubnubCrypto pubnubCrypto = new PubnubCrypto ("enigma"); //Deserialized string message = "IDjZE9BHSjcX67RddfCYYg=="; //Decrypt string decrypted = pubnubCrypto.Decrypt (message); //create an object Object obj = new Object (); //Serialize the object string result = Common.SerializeMiniJson (obj); Assert.True ((decrypted).Equals (result)); }
public void TestGermanCharsDecryption() { PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma"); string message= "stpgsG1DZZxb44J7mFNSzg=="; //decrypt string decrypted= pubnubCrypto.Decrypt(message); //deserialize message= JsonConvert.DeserializeObject<string>(decrypted); Assert.AreEqual("ÜÖ", message); }
public void TestGermanCharsDecryptionMiniJson () { PubnubCrypto pubnubCrypto = new PubnubCrypto ("enigma"); string message = "stpgsG1DZZxb44J7mFNSzg=="; //decrypt string decrypted = pubnubCrypto.Decrypt (message); //deserialize message = Common.DeserializeMiniJson<string> (decrypted); Assert.True (("ÜÖ").Equals (message)); }
public void TestNullDecryption () { PubnubCrypto pubnubCrypto = new PubnubCrypto ("enigma"); //deserialized string string message = null; //decrypt string decrypted = pubnubCrypto.Decrypt (message); Assert.True (("").Equals (decrypted)); }
public void TestUnicodeCharsDecryptionJSONFx() { PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma"); string message = "+BY5/miAA8aeuhVl4d13Kg=="; //decrypt string decrypted = pubnubCrypto.Decrypt(message); //deserialize message = Common.DeserializeUsingJSONFx<string>(decrypted); Assert.AreEqual("漢語", message); }
public void TestPubNubDecryption1JSONFx() { PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma"); //deserialized string string message = "f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0="; //decrypt string decrypted = pubnubCrypto.Decrypt(message); //deserialize message = Common.DeserializeUsingJSONFx<string>(decrypted); Assert.AreEqual("Pubnub Messaging API 1", message); }
public void TestHashDecryption() { PubnubCrypto pc = new PubnubCrypto("enigma"); //deserialized string string message = "GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g="; //decrypt string decryptedMessage = pc.Decrypt(message); Assert.AreEqual("{\"foo\":{\"bar\":\"foobar\"}}", decryptedMessage); }
public void TestMyObjectDecryptionJSONFx() { PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma"); //Deserialized string message = "Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE="; //Decrypt string decrypted = pubnubCrypto.Decrypt(message); //create an object of the custom class CustomClass cc = new CustomClass(); //Serialize it string result = Common.SerializeUsingJSONFx(cc); Assert.AreEqual(decrypted, result); }
public void TestObjectDecryptionJSONFx() { PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma"); //Deserialized string message = "IDjZE9BHSjcX67RddfCYYg=="; //Decrypt string decrypted = pubnubCrypto.Decrypt(message); //create an object Object obj = new Object(); //Serialize the object string result = Common.SerializeUsingJSONFx(obj); Assert.AreEqual(decrypted, result); }
public void TestUnicodeCharsDecryption() { PubnubCrypto pc = new PubnubCrypto("enigma"); string message = "+BY5/miAA8aeuhVl4d13Kg=="; //decrypt string decryptedMessage = pc.Decrypt(message); //deserialize message = (decryptedMessage != "**DECRYPT ERROR**") ? JsonConvert.DeserializeObject<string>(decryptedMessage) : ""; Assert.AreEqual("漢語", message); }
public void TestStuffcanDecryption () { PubnubCrypto pubnubCrypto = new PubnubCrypto ("enigma"); //deserialized string string message = "zMqH/RTPlC8yrAZ2UhpEgLKUVzkMI2cikiaVg30AyUu7B6J0FLqCazRzDOmrsFsF"; //decrypt string decrypted = pubnubCrypto.Decrypt (message); Assert.True (("{\"this stuff\":{\"can get\":\"complicated!\"}}").Equals (decrypted)); }
public void TestHashDecryption () { PubnubCrypto pubnubCrypto = new PubnubCrypto ("enigma"); //deserialized string string message = "GsvkCYZoYylL5a7/DKhysDjNbwn+BtBtHj2CvzC4Y4g="; //decrypt string decrypted = pubnubCrypto.Decrypt (message); Assert.True (("{\"foo\":{\"bar\":\"foobar\"}}").Equals (decrypted)); }
public void TestGermanCharsDecryptionJSONFx() { PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma"); string message = "stpgsG1DZZxb44J7mFNSzg=="; //decrypt string decrypted = pubnubCrypto.Decrypt(message); //deserialize message = Common.DeserializeUsingJSONFx<string>(decrypted); Assert.AreEqual("ÜÖ", message); }
public void TestUnicodeCharsDecryptionMiniJson () { PubnubCrypto pubnubCrypto = new PubnubCrypto ("enigma"); string message = "+BY5/miAA8aeuhVl4d13Kg=="; //decrypt string decrypted = pubnubCrypto.Decrypt (message); //deserialize message = Common.DeserializeMiniJson<string> (decrypted); Assert.True (("漢語").Equals (message)); }
public void TestArrayDecryptionUsingMiniJson () { PubnubCrypto pubnubCrypto = new PubnubCrypto ("enigma"); //Input the deserialized string string message = "Ns4TB41JjT2NCXaGLWSPAQ=="; //decrypt string decrypted = pubnubCrypto.Decrypt (message); //create a serialized object object[] objArr = { }; string result = Common.SerializeMiniJson (objArr); //compare the serialized object and the return of the Decrypt method Assert.True ((result).Equals (decrypted)); }
public void TestPubNubDecryption2JSONFx() { PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma"); //Deserialized string string message = "f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54="; //Decrypt string decrypted = pubnubCrypto.Decrypt(message); //Deserialize message = Common.DeserializeUsingJSONFx<string>(decrypted); Assert.AreEqual("Pubnub Messaging API 2", message); }
public void TestUnicodeCharsDecryption() { PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma"); string message= "+BY5/miAA8aeuhVl4d13Kg=="; //decrypt string decrypted= pubnubCrypto.Decrypt(message); //deserialize message= JsonConvert.DeserializeObject<string>(decrypted); Assert.AreEqual("漢語", message); }