Esempio n. 1
0
        internal static void SaveEncryptedFile(string data, string pass, bool standardMode, bool toHex)
        {
            DataCrypto dataCrypto = new DataCrypto();

            byte[] text = dataCrypto.OpenSSLEncrypt(data, pass);
            if (toHex)
            {
            }
            data       = null;
            dataCrypto = null;
            pass       = null;

            if (!standardMode)
            {
                CallSaveFileDialog(Convert.ToBase64String(text));
            }
            else if (toHex)
            {
                CallSaveFileDialog(BitConverter.ToString(text));
            }
            else
            {
                CallSaveFileDialog(text);
            }
            text = null;
        }
Esempio n. 2
0
        internal static void SaveDecryptedFile(byte[] data, string pass)
        {
            DataCrypto dataCrypto = new DataCrypto();
            string     text       = dataCrypto.OpenSSLDecrypt(data, pass);

            data       = null;
            dataCrypto = null;
            pass       = null;

            if (text.Equals(""))
            {
                return;
            }
            CallSaveFileDialog(text);
            text = null;
        }
Esempio n. 3
0
        internal static void OpenFile(string location, string pass)
        {
            byte[]     data       = CallOpenFileDialogB(location);
            Cryption   cryption   = new Cryption(false);
            DataCrypto dataCrypto = new DataCrypto();

            cryption.dataContent.Text = dataCrypto.OpenSSLDecrypt(data, pass);
            data       = null;
            dataCrypto = null;
            pass       = "";

            if (cryption.dataContent.Text.Equals(""))
            {
                cryption = null;
                return;
            }

            cryption.Show();
            App.Current.MainWindow.Close();
        }
Esempio n. 4
0
        //PASS PANEL CONTROLLERS
        private void OpenDataLocal(object sender, RoutedEventArgs e)
        {
            if (dataContent.Text == "" || passField.Password == "")
            {
                MessageBox.Show("Text is empty!");
                CleanPassWithContext(true);
                return;
            }

            DataCrypto dataCrypto = new DataCrypto();

            if (!encStateBool) //Decryption
            {
                string text = "";
                if (!crypTypeStandardBool) //From Base64
                {
                    text = dataCrypto.OpenSSLDecrypt(Convert.FromBase64String(dataContent.Text), passField.Password);
                }
                else if (crypTypeStandardBool && fromBitConverterResult) //From Hex
                {
                    var data = GetBytes(dataContent.Text);
                    if (data == null)
                    {
                        MessageBox.Show("Can't get bytes! Incorrect input data!");
                        CleanPassWithContext(false);
                        return;
                    }
                    text = dataCrypto.OpenSSLDecrypt(data, passField.Password);
                    data = null;
                }
                else if (crypTypeStandardBool && !fromBitConverterResult) //From standard
                {
                    MessageBox.Show("This mode doesn't work correct. Please, change it and try again!");
                    CleanPassWithContext(false);
                    return;
                }

                if (text.Equals(""))
                {
                    CleanPassWithContext(false);
                    dataCrypto = null;
                    text       = null;
                    MessageBox.Show("Error while trying to decrypt data!");
                    return;
                }

                if (toBitConverterResult) //to something
                {
                    dataContent.Text = BitConverter.ToString(Encoding.ASCII.GetBytes(text));
                }
                else
                {
                    dataContent.Text = text;
                }

                text         = null;
                encStateBool = true;
                CustomizationView();
            }
            else //Encryption
            {
                if (passField.Password.Equals(passCheckField.Password))
                {
                    byte[] data = dataCrypto.OpenSSLEncrypt(dataContent.Text, passField.Password);
                    if (!crypTypeStandardBool) //To Base64
                    {
                        dataContent.Text = Convert.ToBase64String(data);
                    }
                    else if (crypTypeStandardBool && !toBitConverterResult) //To Standard
                    {
                        dataContent.Text = Encoding.ASCII.GetString(data);
                    }
                    else if (crypTypeStandardBool && toBitConverterResult) //To Hex
                    {
                        dataContent.Text = BitConverter.ToString(data);
                    }
                    data = null;
                }
                else
                {
                    MessageBox.Show("Passwords are not same!");
                    return;
                }
                encStateBool = false;
                CustomizationView();
            }
            CleanPassWithContext(false);
            dataCrypto = null;
        } //Exist