public string getdecrypt(byte[] encryptedMessage) { byte[] encrypted; string roundtrip; // Create a new instance of the Aes // class. This generates a new key and initialization // vector (IV). // Decrypt the string to an array of bytes. roundtrip = AESCryptoSystem.Decrypt(encryptedMessage, Key, IV); Dictionary <string, object> json = new Dictionary <string, object>(); json.Add("encrypt", roundtrip); return(JsonConvert.SerializeObject(json)); }
public string aes(string messageToEncrypt) { string msg = messageToEncrypt; byte[] encrypted; string roundtrip; // Encrypt the string to an array of bytes. encrypted = AESCryptoSystem.Encrypt(msg, Key, IV); // Decrypt the bytes to a string. roundtrip = AESCryptoSystem.Decrypt(encrypted, Key, IV); Dictionary <string, object> json = new Dictionary <string, object>(); json.Add("data", msg); json.Add("encrypt", encrypted); json.Add("decrypt", roundtrip); return(JsonConvert.SerializeObject(json)); }