Exemple #1
0
        private void envelopeEncryptStart_Click(object sender, EventArgs e)
        {
            var ready = true;

            if (string.IsNullOrWhiteSpace(envelopeEncryptPlain.Text))
            {
                MessageBox.Show("Choose a file for encryption", "Choose plain text", MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                ready = false;
            }
            if (string.IsNullOrWhiteSpace(envelopeEncryptPublic.Text))
            {
                envelopeEncryptPlain.Text = _initialDirectory + "RSA_public.txt";
            }
            if (string.IsNullOrWhiteSpace(rsaEncryptCipherFile.Text))
            {
                envelopeEncryptEnvelope.Text = _initialDirectory + "envelope.txt";
            }

            if (ready)
            {
                DigitalEnvelope.CreateEnvelope(envelopeEncryptPlain.Text, int.Parse(rsaKeysSize.Text),
                                               envelopeEncryptPublic.Text, envelopeEncryptEnvelope.Text);
            }
        }
Exemple #2
0
        public static void CreateSignedEnvelope(string plainTextFile, int keySize, string receiverPublicKeyFilePath,
                                                string senderPrivateKeyFilePath, string outputFilePath)
        {
            var tmpEnvelopeFilePath = Environment.CurrentDirectory + @"\Files\tmp\envelope_tmp.txt";

            DigitalEnvelope.CreateEnvelope(plainTextFile, keySize, receiverPublicKeyFilePath,
                                           tmpEnvelopeFilePath);

            DigitalSignature.CreateEnvelopeSignature(tmpEnvelopeFilePath, keySize, senderPrivateKeyFilePath,
                                                     outputFilePath);
        }