public string Encrypt <T>(T obj) where T : new() { var prop = GetPropertiesToEncrypt(typeof(T)); var jObject = JObject.FromObject(obj); foreach (var p in prop) { if (p.CanRead && p.CanWrite) { var value = p.GetValue(obj); var bytes = _byteSerializer.Serialize(value); bytes = _encrypting.Protect(bytes); jObject[p.Name] = bytes; } } return(jObject.ToString(Formatting.Indented)); }