public void EncriptAndDecryptBytes() { byte[] input = { 0x00, 0x12, 0x64, 0x12, 0x00, 0x19, 0xff, 0x55 }; byte[] encrypted, decrypted; using (var s3des = new SimpleTripleDES(EncryptionKey)) encrypted = s3des.Encrypt(input); using (var s3des = new SimpleTripleDES(EncryptionKey)) decrypted = s3des.Decrypt(encrypted); Assert.AreEqual(input, decrypted); }
public object Bind(SmartDispatcherController controller, ParameterInfo parameterInfo) { if (String.IsNullOrEmpty(parameterName)) parameterName = parameterInfo.Name; string value = controller.Request.Params[parameterName]; if (String.IsNullOrEmpty(value)) return null; using (var s3des = new SimpleTripleDES(key)) return s3des.DecryptObjectFromBase64(AdjustBase64ForUrlUsage(false, value)); }
public void EncriptAndDecryptComplexTest() { var text = "<alô, mundo CÃO!\ntudo certo?>"; string encrypted, decrypted; using (var s3des = new SimpleTripleDES(EncryptionKey)) encrypted = s3des.Encrypt(text); using (var s3des = new SimpleTripleDES(EncryptionKey)) decrypted = s3des.Decrypt(encrypted); Assert.AreEqual(text, decrypted); }
public void EncriptAndDecryptSimpleText() { var text = "alo mundo"; string encrypted, decrypted; using (var s3des = new SimpleTripleDES(EncryptionKey)) encrypted = s3des.Encrypt(text); using (var s3des = new SimpleTripleDES(EncryptionKey)) decrypted = s3des.Decrypt(encrypted); Console.WriteLine("original : {0}", text); Console.WriteLine("encrypted: {0}", encrypted); Console.WriteLine("decrypted: {0}", decrypted); Assert.AreEqual(text, decrypted); }
public object Bind(SmartDispatcherController controller, ParameterInfo parameterInfo) { if (String.IsNullOrEmpty(parameterName)) { parameterName = parameterInfo.Name; } string value = controller.Request.Params[parameterName]; if (String.IsNullOrEmpty(value)) { return(null); } using (var s3des = new SimpleTripleDES(key)) return(s3des.DecryptObjectFromBase64(AdjustBase64ForUrlUsage(false, value))); }
public static string Encrypt(string key, object obj) { using (var s3des = new SimpleTripleDES(key)) return AdjustBase64ForUrlUsage(true, s3des.EncryptObjectToBase64(obj)); }
public static string Encrypt(string key, object obj) { using (var s3des = new SimpleTripleDES(key)) return(AdjustBase64ForUrlUsage(true, s3des.EncryptObjectToBase64(obj))); }