public void SetString(string key, string value, string password) { var desEncryption = new DESEncryption (); string hashedKey = GenerateMD5 (key); string encryptedValue = desEncryption.Encrypt (value, password); PlayerPrefs.SetString (hashedKey, encryptedValue); }
private void btnEncrypt_Click(object sender, EventArgs e) { if (tbPassword.Text.Length != 8) { WarningNotice.KeyLength(8); return; } if (tbIV.Text.Length != 8) { WarningNotice.IVLength(8); return; } tbToText.Text = DESEncryption.Encrypt(tbFromText.Text, tbPassword.Text, tbIV.Text); }
public static bool SaveData() { const bool valid = false; try { GAME_DATA.SaveData(); var result = DESEncryption.Encrypt(JsonUtility.ToJson(SessionData.GAME_DATA)); PlayerPrefs.SetString("data", result); PlayerPrefs.Save(); } catch (Exception ex) { Debug.LogError(ex.ToString()); } return(valid); }
private void btnFileSave1_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(tbPath.Text)) { WarningNotice.InputString(); return; } if (!File.Exists(tbPath.Text)) { WarningNotice.NotFound(); return; } if (tbPassword.Text.Length != 8) { WarningNotice.KeyLength(8); return; } if (tbIV.Text.Length != 8) { WarningNotice.IVLength(8); return; } if (DialogResult.OK == sfdFile.ShowDialog()) { FileInfo file = new FileInfo(tbPath.Text); FileInfo result = new FileInfo(sfdFile.FileName); fileSize = file.Length; Task.Factory.StartNew(() => { ControlEnable(this.Controls, false); DESEncryption.Encrypt(file, result, tbPassword.Text, tbIV.Text); this.Invoke(new Action(() => WarningNotice.Save())); ControlEnable(this.Controls, true); }); } sfdFile.FileName = ""; }