Beispiel #1
0
        private void button2_Click_1(object sender, EventArgs e)
        {
            try
            {
                var container = CSFContainer.Load(openFileDialog.FileName, textBoxKey.Text);
                this.container = container;

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception err)
            {
                try
                {
                    var container = CSFContainer.Load(openFileDialog.FileName, textBoxKey.Text, true);
                    this.container = container;

                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                catch (Exception err2)
                {
                    //System.Windows.Forms.MessageBox.Show(err2.ToString());
                    System.Windows.Forms.MessageBox.Show("There was a problem loading this container. Please make sure that the key you provided is correct and check if the file you chose is a proper container.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            CreateContainerWindow frm = new CreateContainerWindow();

            if (frm.ShowDialog() != DialogResult.Cancel)
            {
                this.container = frm.container;
                FillFileList();
                label1.Text     = "Total Size: " + (new System.IO.FileInfo(container.Path).Length / 1024).ToString() + " Kb";
                button3.Enabled = button4.Enabled = button5.Enabled = true;
            }
        }
Beispiel #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            LoadContainerWindow frm = new LoadContainerWindow();

            if (frm.ShowDialog() == DialogResult.OK)
            {
                this.container = frm.container;
                FillFileList();

                this.Text = "CSFProject - " + container.Path;

                label1.Text     = "Total Size: " + (new System.IO.FileInfo(container.Path).Length / 1024).ToString() + " Kb";
                button3.Enabled = button4.Enabled = button5.Enabled = button7.Enabled = true;
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBoxKey.Text.Length < 12)
            {
                System.Windows.Forms.MessageBox.Show("Must have a password of at least 12 characters!", "Error - Password too short", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (textBoxKey.Text != textBox2.Text)
            {
                System.Windows.Forms.MessageBox.Show("There is a mismatch between the key that you provided and the key confirmation.", "Error - Keys mismatch", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (checkBox2.Checked)
            {
                if (textBoxKey.Text.Length < 12)
                {
                    System.Windows.Forms.MessageBox.Show("Must have a hidden key of at least 12 characters!", "Error - Hidden key too short", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (textBoxKey.Text != textBox2.Text)
                {
                    System.Windows.Forms.MessageBox.Show("There is a mismatch between the hidden key that you provided and the hidden key confirmation.", "Error - Keys mismatch", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                CSFContainer container = new CSFContainer(textBoxKey.Text, checkBox1.Checked);
                this.container = container;
                container.Create(textBox1.Text, true, textBox3.Text);
            }
            else
            {
                CSFContainer container = new CSFContainer(textBoxKey.Text, checkBox1.Checked);
                this.container = container;
                container.Create(textBox1.Text);
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
        private void button3_Click_1(object sender, EventArgs e)
        {
            // saveFileDialog1.ShowDialog();

            SaveContainerWindow ste = new SaveContainerWindow(this.containerBytes);

            if (ste.ShowDialog() != DialogResult.Cancel)
            {
                this.container = ste.container;

                this.DialogResult = DialogResult.OK;

                this.Close();
            }



            //container = CSFContainer.Load(openFileDialog1.FileName, textBoxKey.Text);


            //System.IO.File.WriteAllText(container.Path, container);
        }
        static void Main(string[] args)
        {
            int          switchExpression = 0;
            CSFContainer container        = null;
            bool         submenu          = false;

            while (true)
            {
                Console.WriteLine("[1] Create Container");
                Console.WriteLine("[2] Open Container");
                if (submenu)
                {
                    Console.WriteLine("[3] List Files");
                    Console.WriteLine("[4] Add File");
                    Console.WriteLine("[5] Extract File");
                    Console.WriteLine("[6] Delete File");
                }
                ;

                switchExpression = Convert.ToInt32(Console.ReadLine());
                if (!submenu)
                {
                    if (switchExpression > 2)
                    {
                        switchExpression = 7;
                    }
                }
                switch (switchExpression)
                {
                case 1:
                    Console.WriteLine("[1]Create Container");
                    Console.WriteLine("Choose Container path:");
                    string name = Console.ReadLine();
                    Console.WriteLine("Choose Container Password:"******"Obfuscate the sizes of the files ? [Y/N]");
                    string decision         = Console.ReadLine();
                    bool   addRandomBuffers = false;
                    if (decision == "Y" | decision == "y")
                    {
                        addRandomBuffers = true;
                    }
                    CSFContainer container1 = new CSFContainer(pass, addRandomBuffers);
                    container = container1;
                    container.Create(name);
                    submenu = true;

                    break;

                case 2:
                    Console.WriteLine("[2] Open Container");
                    Console.WriteLine("Container path:");
                    name = Console.ReadLine();
                    Console.WriteLine("Container Password:"******"There was a problem loading this container. Please make sure that the key you provided is correct and check if the file you chose is a proper container." + "\n");
                        break;
                    }
                    submenu = true;
                    break;

                case 3:
                    Console.WriteLine("[3] List Files");
                    foreach (var file in container.Files)
                    {
                        if (file.Dummy)
                        {
                            continue;
                        }
                        Console.Write(file.Name + "\n");
                    }
                    Console.Write("Total Size: " + (new System.IO.FileInfo(container.Path).Length / 1024).ToString() + " Kb" + "\n");
                    break;

                case 4:
                    Console.WriteLine("[4] Add File");
                    Console.WriteLine("Write file path");
                    name = Console.ReadLine();
                    container.AddFile(name);

                    break;

                case 5:
                    Console.WriteLine("[4] Extract File");
                    Console.WriteLine("Choose file");
                    int i = 1;
                    foreach (var file in container.Files)
                    {
                        if (file.Dummy)
                        {
                            i++;
                            continue;
                        }
                        Console.Write("[" + i + "]" + file.Name + "\n");
                        i++;
                    }
                    int filen = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("Write path to extract");
                    string path = Console.ReadLine();
                    container.ExtractFile(filen - 1, path);

                    break;

                case 6:
                    Console.WriteLine("[5] Delete File");
                    Console.WriteLine("Choose File");
                    i = 1;
                    foreach (var file in container.Files)
                    {
                        if (file.Dummy)
                        {
                            i++;
                            continue;
                        }

                        Console.Write("[" + i + "]" + file.Name + "\n");
                        i++;
                    }
                    Console.WriteLine("Choose File");
                    i = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("Are you sure you want to permanently remove this file ? [Y/N]");
                    string decision1 = Console.ReadLine();
                    if (decision1 == "Y" | decision1 == "y")
                    {
                        container.RemoveFile(i - 1);
                    }
                    break;

                default:
                    Console.WriteLine("Option not recognizable");
                    break;
                }
            }
        }