资源简介

配置文件ini内容加密

资源截图

代码片段和文件信息

using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Encryption
{
    public partial class MainForm : Form
    {
        private static char[] base64CodeArray = new char[]
        {
            ‘A‘ ‘B‘ ‘C‘ ‘D‘ ‘E‘ ‘F‘ ‘G‘ ‘H‘ ‘I‘ ‘J‘ ‘K‘ ‘L‘ ‘M‘ ‘N‘ ‘O‘ ‘P‘ ‘Q‘ ‘R‘ ‘S‘ ‘T‘ ‘U‘ ‘V‘ ‘W‘ ‘X‘ ‘Y‘ ‘Z‘
            ‘a‘ ‘b‘ ‘c‘ ‘d‘ ‘e‘ ‘f‘ ‘g‘ ‘h‘ ‘i‘ ‘j‘ ‘k‘ ‘l‘ ‘m‘ ‘n‘ ‘o‘ ‘p‘ ‘q‘ ‘r‘ ‘s‘ ‘t‘ ‘u‘ ‘v‘ ‘w‘ ‘x‘ ‘y‘ ‘z‘
            ‘0‘ ‘1‘ ‘2‘ ‘3‘ ‘4‘  ‘5‘ ‘6‘ ‘7‘ ‘8‘ ‘9‘ ‘+‘ ‘/‘ ‘=‘
        };
        public MainForm()
        {
            InitializeComponent();
        }
        /// 
        /// 是否base64字符串
        /// 

        /// se64Str“>要判断的字符串
        /// 字符串转换成的字节数组
        /// 
        public static bool Isbase64(string base64Str out byte[] bytes)
        {
            bytes = null;
            if (string.IsNullOrEmpty(base64Str))
                return false;
            else
            {
                if (base64Str.Contains(““))
                    base64Str = base64Str.Split(‘‘)[1];
                if (base64Str.Length % 4 != 0)
                    return false;
                if (base64Str.Any(c => !base64CodeArray.Contains(c)))
                    return false;
            }
            try
            {
                bytes = Convert.Frombase64String(base64Str);
                return true;
            }
            catch (FormatException)
            {
                return false;
            }
        }

        private void btEn_Click(object sender EventArgs e)
        {
            byte[] bytes = Encoding.Default.GetBytes(tbContent.Text);
            tbEnContent.Text = Convert.Tobase64String(bytes);
        }

        private void btDe_Click(object sender EventArgs e)
        {
            byte[] outputb = Convert.Frombase64String(tbEnContent.Text);
            tbContent.Text = Encoding.Default.GetString(outputb);
        }

        private void btSave_Click(object sender EventArgs e)
        {
            SaveFileDialog save = new SaveFileDialog();
            save.InitialDirectory = “C:\\“;
            save.FileName = “Config.ini“;
            save.RestoreDirectory = true;
            save.FilterIndex = 1;
            if (save.ShowDialog() == DialogResult.OK)
            {
                string str = save.FileName;
                //向指定的文件中追加内容,如果文件不存在,则创建文件
                StreamWriter sw = File.CreateText(str);
                sw.Write(tbEnContent.Text);
                sw.Flush();
                sw.Close();
                MessageBox.Show(“保存成功“ “提示“ MessageBoxButtons.OK);
            }
        }

        private void btOpen_Click(object sender EventArgs e)
        {
            tbContent.Text = ““;
            tbEnContent.Text

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.     68608  2020-08-29 16:50  Encryption\.vs\Encryption\v14\.suo

     文件      13312  2020-08-29 16:19  Encryption\Encryption\bin\Debug\Encryption.exe

     文件      24064  2020-08-29 16:19  Encryption\Encryption\bin\Debug\Encryption.pdb

     文件      21680  2020-08-29 16:41  Encryption\Encryption\bin\Debug\Encryption.vshost.exe

     文件        490  2019-03-19 12:46  Encryption\Encryption\bin\Debug\Encryption.vshost.exe.manifest

     文件       3703  2020-08-27 17:36  Encryption\Encryption\Encryption.csproj

     文件       4989  2020-08-29 16:50  Encryption\Encryption\MainForm.cs

     文件       8090  2020-08-28 12:35  Encryption\Encryption\MainForm.Designer.cs

     文件       5817  2020-08-28 12:35  Encryption\Encryption\MainForm.resx

     文件       1230  2020-08-29 15:56  Encryption\Encryption\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6834  2020-08-28 11:06  Encryption\Encryption\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        693  2020-08-29 16:41  Encryption\Encryption\obj\Debug\Encryption.csproj.FileListAbsolute.txt

     文件        908  2020-08-28 12:35  Encryption\Encryption\obj\Debug\Encryption.csproj.GenerateResource.Cache

     文件       1758  2020-08-27 17:12  Encryption\Encryption\obj\Debug\Encryption.csprojResolveAssemblyReference.cache

     文件      13312  2020-08-29 16:19  Encryption\Encryption\obj\Debug\Encryption.exe

     文件        180  2020-08-28 12:35  Encryption\Encryption\obj\Debug\Encryption.MainForm.resources

     文件      24064  2020-08-29 16:19  Encryption\Encryption\obj\Debug\Encryption.pdb

     文件        180  2020-08-27 17:36  Encryption\Encryption\obj\Debug\Encryption.Properties.Resources.resources

     文件        494  2020-08-27 17:12  Encryption\Encryption\Program.cs

     文件       1328  2020-08-27 17:08  Encryption\Encryption\Properties\AssemblyInfo.cs

     文件       2833  2020-08-27 17:08  Encryption\Encryption\Properties\Resources.Designer.cs

     文件       5612  2020-08-27 17:08  Encryption\Encryption\Properties\Resources.resx

     文件       1097  2020-08-27 17:08  Encryption\Encryption\Properties\Settings.Designer.cs

     文件        249  2020-08-27 17:08  Encryption\Encryption\Properties\Settings.settings

     文件        997  2020-08-27 17:09  Encryption\Encryption.sln

     目录          0  2020-08-27 17:08  Encryption\Encryption\obj\Debug\TempPE

     目录          0  2020-08-27 17:09  Encryption\.vs\Encryption\v14

     目录          0  2020-08-28 11:07  Encryption\Encryption\bin\Debug

     目录          0  2020-08-29 15:56  Encryption\Encryption\obj\Debug

     目录          0  2020-08-27 17:08  Encryption\.vs\Encryption

............此处省略9个文件信息

评论

共有 条评论