public static string GetEncryptedString(string value, string password) { if (string.IsNullOrEmpty(value)) { return(string.Empty); } try { return(AESUtility.Encrypt(value, password)); } catch (Exception) { return(string.Empty); } }
public static bool SaveToFile <T>(this T item, string filePath, bool isEncrypt = false, string password = "") where T : IFileSerializable, IJSONSerializable { Utility.CreateDirectory(filePath); var jToken = item.ToJSON(); if (jToken == null) { return(false); } string jsonText = jToken.ToString(Newtonsoft.Json.Formatting.Indented); if (isEncrypt) { jsonText = AESUtility.Encrypt(jsonText, password); } File.WriteAllText(filePath, jsonText); return(true); }