public JObject SaveEncrypt([FromBody] RequestEncrypted request) { var key = Convert.FromBase64String(request.Key); //Encoding.UTF8.GetBytes(request.Key); var iv = Convert.FromBase64String(request.IV); //Encoding.UTF8.GetBytes(request.IV); string encrypted = string.Empty; string decrypt = string.Empty; if (!string.IsNullOrEmpty(request.PlainText)) { encrypted = SioService.EncryptStringToBytes_Aes(request.PlainText, key, iv).ToString(); } if (!string.IsNullOrEmpty(request.Encrypted)) { decrypt = SioService.DecryptStringFromBytes_Aes(request.Encrypted, key, iv); } JObject data = new JObject( new JProperty("key", request.Key), new JProperty("encrypted", encrypted), new JProperty("plainText", decrypt)); return(data); }