private void LoadLogClientData() { lock (LockObj) { if (!File.Exists(encryptionKeyFullFilename)) { key = GetRandomKey(); // write user initial config file string strLogClientConfigInit = File.ReadAllText(logClientConfigInitFullFilename, Encoding.Default); string strEncryptedLogClientConfigInit = TranString.EncodeAES(strLogClientConfigInit, key); if (File.Exists(encryptedlogClientConfigContentsFullFilename)) { File.Delete(encryptedlogClientConfigContentsFullFilename); } File.WriteAllText(encryptedlogClientConfigContentsFullFilename, strEncryptedLogClientConfigInit); } // read user config file key = GetRandomKey(); string CryptedConfigFile = File.ReadAllText(encryptedlogClientConfigContentsFullFilename, Encoding.Default); string PlainConfigFile = TranString.DecodeAES(CryptedConfigFile, key); string2List(PlainConfigFile, listData); LoadDataList2Dictionary(listData, dicData); } }
private void buttonDecode_Click(object sender, EventArgs e) { try { switch (algorithm) { case Algorithm.Base64Unicode: textBoxDecode.Text = TranString.DecodeBase64Unicode(textBoxEncode.Text); break; case Algorithm.Base64: textBoxDecode.Text = TranString.DecodeBase64(textBoxEncode.Text); break; case Algorithm.UrlEncode: textBoxDecode.Text = TranString.DecodeUrlDecode(textBoxEncode.Text); break; case Algorithm.AES: textBoxDecode.Text = TranString.DecodeAES(textBoxEncode.Text, textBoxKey.Text); break; case Algorithm.Rijndael: textBoxDecode.Text = TranString.DecodeRijndael(textBoxEncode.Text, textBoxRijndaelKey.Text, textBoxRijndaelVector.Text); break; default: throw new ArgumentOutOfRangeException($"algorithm : {algorithm}"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void LoadUserData() { lock (LockObj) { if (!File.Exists(encryptionKeyFullFilename)) { key = GetRandomKey(); // write user initial config file string strDataManagerContentsInitFullFilename = File.ReadAllText(dataManagerContentsInitFullFilename, Encoding.Default); string strEncryptedDataManagerContentsInit = TranString.EncodeAES(strDataManagerContentsInitFullFilename, key); // 암호키를 지우면 데이터 파일을 다시 만든다. if (File.Exists(encryptedDataManagerContentsFullFilename)) { File.Delete(encryptedDataManagerContentsFullFilename); } File.WriteAllText(encryptedDataManagerContentsFullFilename, strEncryptedDataManagerContentsInit); } // read user config file key = GetRandomKey(); string CryptedConfigFile = File.ReadAllText(Path.Combine(path, encryptedDataManagerContentsFullFilename), Encoding.Default); string PlainConfigFile = TranString.DecodeAES(CryptedConfigFile, key); string2List(PlainConfigFile, listData); LoadDataList2Dictionary(listData, dicData); var logintype = dicData[new Tuple <Category, Key>(Category.Login, Key.LoginType)]; LoginType = (LoginType)Enum.Parse(typeof(LoginType), logintype); } }
public void LoadUserData() { lock (LockObj) { if (!File.Exists(encryptionKeyFullFilename)) { key = GetRandomKey(); // write user initial config file string strDataManagerContentsInitFullFilename = File.ReadAllText(dataManagerContentsInitFullFilename, Encoding.Default); string strEncryptedDataManagerContentsInit = TranString.EncodeAES(strDataManagerContentsInitFullFilename, key); if (File.Exists(encryptedDataManagerContentsFullFilename)) { File.Delete(encryptedDataManagerContentsFullFilename); } else { File.WriteAllText(encryptedDataManagerContentsFullFilename, strEncryptedDataManagerContentsInit); } } // read user config file key = GetRandomKey(); string CryptedConfigFile = File.ReadAllText(Path.Combine(path, encryptedDataManagerContentsFullFilename), Encoding.Default); string PlainConfigFile = TranString.DecodeAES(CryptedConfigFile, key); string2List(PlainConfigFile, listData); LoadDataList2Dictionary(listData, dicData); } }