예제 #1
0
        private void btnDecrypt_Click(object sender, EventArgs e)
        {
            // Decrypt(pathEncryptedFile.Text, pathOriginalFile.Text, textKey.Text, textIV.Text);
            Cryptosystem algorithm = null;

            switch (this.CipherType)
            {
            case (int)Cipher.tRijndael:
                algorithm = new Algorithm.m_Rijndael(textKey.Text, textIV.Text);
                break;

            case (int)Cipher.tAES:
                algorithm = new Algorithm.m_AES(textKey.Text, textIV.Text);
                break;

            default:
                algorithm = null;
                break;
            }
            if (algorithm == null)
            {
                return;
            }
            if (algorithm.IsValidKey() == false)
            {
                MessageBox.Show("Wrong format key string");
            }
            else
            {
                algorithm.Decrypt(pathEncryptedFile.Text, pathOriginalFile.Text);
            }
        }
예제 #2
0
        private void btnEncrypt_Click(object sender, EventArgs e)
        {
            Cryptosystem algorithm = null;

            switch (this.CipherType)
            {
            case (int)Cipher.tRijndael:
                algorithm = new Algorithm.m_Rijndael(textKey.Text, textIV.Text);
                break;

            case (int)Cipher.tAES:
                algorithm = new Algorithm.m_AES(textKey.Text, textIV.Text);
                break;

            default:
                algorithm = null;
                break;
            }
            if (algorithm == null)
            {
                return;
            }
            if (algorithm.IsValidKey() == false)
            {
                MessageBox.Show("Lengthes of key and iv are not correct");
            }
            else
            {
                algorithm.Encrypt(pathOriginalFile.Text, pathEncryptedFile.Text);
            }
        }