Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            if (args.Length != 0)
            {
                try
                {
                    string path = args[1];
                    Byte[] data;
                    Form1.Getdata(path, out data);
                    Byte[]          output;
                    KaisaEnCryption kaisaEn = new KaisaEnCryption(Form1.getkey(Form1.GetNetworkAdpaterID()));
                    switch (Convert.ToInt32(args[0]))
                    {
                    case 1:
                        kaisaEn.encrypt(data, out output);
                        Form1.SaveData(path, output);
                        MessageBox.Show("快速加密成功!");
                        break;

                    case 2:
                        kaisaEn.decrypt(data, out output);
                        Form1.SaveData(path, output);
                        MessageBox.Show("快速解密成功!");
                        break;

                    default:
                        output = data;
                        break;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }

                return;
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
Ejemplo n.º 2
0
        private void BtnDo_Click(object sender, EventArgs e)
        {
            if (!(File.Exists(TextB_OpenPath.Text) && TextBdestinationPath.Text.Length != 0))
            {
                MessageBox.Show("请输入正确的文件名和目标地址");
                return;
            }
            if (encryptionlist.EnList.Count == 0 && !ToolStripMenuItemLocalEn.Checked)
            {
                MessageBox.Show("请读入或添加密钥");
                return;
            }
            if (!ToolStripMenuItemOverride.Checked && File.Exists(TextBdestinationPath.Text) && MessageBox.Show("目标文件已存在\r\n是否覆盖?", "文件加密器", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
            {
                return;
            }
            Byte[] data;
            Byte[] output;
            Byte[] temp;
            Getdata(TextB_OpenPath.Text, out data);
            KaisaEnCryption kaisaEn = new KaisaEnCryption(getkey(GetNetworkAdpaterID()));
            WeiyiEnCryption weiyi   = new WeiyiEnCryption(1);

            if (SpecialServiceContained() != -1)
            {
                if (status)
                {
                    MessageBox.Show("I feel sorry. 这是一把只能解密的Key");
                    return;
                }
                InputBox inputDialog = new InputBox();
                inputDialog.Text = "";
                Int32 hash = 0;
                foreach (byte element in data)
                {
                    hash = (hash * 31) + element;
                }//哈希算法
                //MessageBox.Show(Convert.ToString(hash));
                Random rand     = new Random();
                int    errorNum = 401 + rand.Next(9);
                switch (hash)
                {
                case -2105041395:
                    inputDialog.text.Text = "提示:2个字,当然啦也许并不需要这个提示hhh";

                    while (inputDialog.ShowDialog() != DialogResult.OK)
                    {
                    }
                    if (inputDialog.Input.Text.Equals("画沙"))
                    {
                        MessageBox.Show("看来记性不错嘛~");
                        while (MessageBox.Show("不过我还有一个请求,看完以后保证不要打我哟", "Last Request", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes)
                        {
                        }
                        MessageBox.Show("好啦好啦给你看~");
                        break;
                    }
                    else
                    {
                        MessageBox.Show(Convert.ToString(errorNum) + " not found");
                        return;
                    }

                case 1946476662:
                case 2051085142:
                    inputDialog.text.Text = "有答案了嘛?";
                    while (inputDialog.ShowDialog() != DialogResult.OK)
                    {
                        ;
                    }
                    if (inputDialog.Input.Text.Equals("2011"))
                    {
                        MessageBox.Show("WooooooW~~\n\r恭喜获得一张钓鲑鱼通行证");
                        break;
                    }
                    else
                    {
                        MessageBox.Show(Convert.ToString(errorNum) + " not found");
                        return;
                    }
                    break;

                default:
                    MessageBox.Show("hhhhh这就是个普通文件嘛 emmm罢工咯~~");
                    return;
                }
            }
            if (status)
            {
#if HOME
                weiyi.encrypt(data, out temp);
                data = temp;
#endif
                if (ToolStripMenuItemLocalEn.Checked)
                {
                    kaisaEn.encrypt(data, out temp);
                    data = temp;
                }
                encryptionlist.encrypt(data, out output);
            }
            else
            {
                encryptionlist.decrypt(data, out output);
                if (ToolStripMenuItemLocalEn.Checked)
                {
                    kaisaEn.decrypt(output, out temp);
                    output = temp;
                }
#if HOME
                weiyi.decrypt(output, out temp);
                output = temp;
#endif
            }
            SaveData(TextBdestinationPath.Text, output);
            if (status)
            {
                if (MessageBox.Show("加密成功!\r\n是否保存该密钥", "文件加密器", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    SaveFileDialog sDlg = new SaveFileDialog();
                    sDlg.Filter = "觉皇密钥文件(*.enc)|*.enc";
                    string s = TextB_OpenPath.Text;
                    int    a = s.LastIndexOf('.');
                    s             = s.Substring(0, a);
                    a             = s.LastIndexOf('\\');
                    s             = s.Substring(a + 1);
                    sDlg.FileName = s;
                    if (sDlg.ShowDialog() == DialogResult.OK)
                    {
                        encryptionlist.saveEncryption(sDlg.FileName);
                    }
                }
            }
            else
            {
                MessageBox.Show("解密成功");
            }
        }