public static void Save(string parent, string username, string password) { if (Global.Password == null) { return; } JObject obj = new JObject(); JToken token = new JObject(); token["username"] = username; token["password"] = password; obj[parent] = token; byte[] data = Encoding.UTF8.GetBytes(obj.ToString()); data = FileEncrypt.Default(data); File.WriteAllBytes("Account.lock", data); }
public bool Save() { Global.DownloadFolder = StringValue(Settings.download_folder) ?? "hitomi_downloaded"; Global.FileEn = BoolValue(Settings.file_encrypt) ?? false; Global.AutoFileEn = BoolValue(Settings.download_file_encrypt) ?? false; Global.EncryptTitle = BoolValue(Settings.encrypt_title) ?? false; Global.RandomTitle = BoolValue(Settings.random_title) ?? false; if (Global.DownloadFolder == "") { Global.DownloadFolder = "hitomi_downloaded"; } string path = encrypt ? Global.Config.encryptpath : Global.Config.path; byte[] bytes = Encoding.UTF8.GetBytes(config.ToString()); if (encrypt) { bytes = FileEncrypt.Encrypt(bytes, Global.Password); } File.WriteAllBytes(path, bytes); return(true); }
public bool Save() { if (Global.MainWindow != null) { Visibility visibility = Visibility.Visible; if (config.password.Get <string>() == null || config.file_encrypt.Get <bool>() == false) { visibility = Visibility.Collapsed; } Global.MainWindow.Encrypt.Visibility = visibility; Global.MainWindow.Decrypt.Visibility = visibility; } string path = encrypt ? Global.Config.encryptpath : Global.Config.path; byte[] bytes = Encoding.UTF8.GetBytes(ToJObject().ToString());//JObject.FromObject(config).ToString()); if (encrypt) { bytes = FileEncrypt.Encrypt(bytes, Global.Password); } File.WriteAllBytes(path, bytes); return(true); }