Exemplo n.º 1
0
        /*
         * private string EncryptTextAes(string value)
         * {
         *  if (string.IsNullOrEmpty(value))
         *  {
         *      return null;
         *  }
         *
         *  byte[] aesIV, aesKey;
         *  Encrypt.MakeKey(EncryptKey, out aesIV, out aesKey);
         *
         *  AesCryptoServiceProvider aes = new AesCryptoServiceProvider();
         *  aes.BlockSize = 128;
         *  aes.KeySize = 256;
         *  aes.IV = aesIV;
         *  aes.Key = aesKey;
         *  aes.Mode = CipherMode.CBC;
         *  aes.Padding = PaddingMode.PKCS7;
         *
         *  byte[] src = Encoding.UTF8.GetBytes(value);
         *
         *  using (ICryptoTransform encrypt = aes.CreateEncryptor())
         *  {
         *      byte[] dest = encrypt.TransformFinalBlock(src, 0, src.Length);
         *      string result = Convert.ToBase64String(dest);
         *      return result;
         *  }
         * }
         */

        private string DecryptText(string value)
        {
            if (EncryptMode == EncryptModeOption.AES)
            {
                value = Encrypt.DecryptText(value);
            }
            else if (EncryptMode == EncryptModeOption.UrlEncode)
            {
                value = Uri.UnescapeDataString(value);
            }
            return(value);
        }
Exemplo n.º 2
0
        private bool LoadFile()
        {
            EncryptManager manager = new EncryptManager();

            manager.EncryptKey = System.Environment.UserName;
            string password2 = manager.DecryptText(Properties.Settings.Default.EncryptKey);

            var configNew = new ConfigAccess();

            configNew.EncryptKey = password2;

            bool success = false;

            FilePath = Path.Combine(ConfigFolder, "Default.xml");
            if (File.Exists(FilePath))
            {
                if (!configNew.Load(FilePath))
                {
                    MessageBox.Show("ファイルの読み込みに失敗しました。");
                    return(false);
                }
                else
                {
                    success = true;
                }
            }

            if (!success)
            {
                configNew.Create();
            }

            Config = configNew;

            TreeNode rootNode = FolderTree.Nodes.Add("Default");

            MakeTree(rootNode, "/");
            rootNode.Expand();
            FolderTree.SelectedNode = rootNode;
            IsLoaded = true;
            return(true);
        }