我有一个小的电子邮件程序,它进行加密.以下只是该计划的摘要:
private void sendEmailButton_Click(object sender, EventArgs e)
{
else
{
//////////////////////////////////////////////////////////////////////////
if (encryptEverythingCheckBox.Checked)
{
encryptAll();
}
//////////////////////////////////////////////////////////////////////////
// Email credentials network codes blahblah
// Assign the sender's email address to MailAddress function
MailAddress mailAddress = new MailAddress(username);
// Tells the recipent the sender's email
mailMessage.From = mailAddress;
// Username & Password of your email address
System.Net.NetworkCredential networkCredential;
networkCredential = new System.Net.NetworkCredential(username, password);
// Enable SSL to encypt the connection
smtpClient.EnableSsl = true;
// Disable the use of default credentials
smtpClient.UseDefaultCredentials …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用公钥编写代码来加密文本,并使用私钥和密码来解密.
我对编程语言不太熟悉,因为我不是编程学生.但对于我的迷你项目,我需要编写一些关于加密的程序.
对于以下代码,使用我的c驱动器中的文本文件来使用公钥进行编码.但我想使用openfiledialog来选择文件,而不是手动指向它(不是很实用)
真的很感激,如果有人可以帮我编辑代码.PS我真的不知道如何将openfiledialog应用于我的代码.当我使用youtubes和google的信息时,我不断收到错误.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using DidiSoft.Pgp;
namespace TEST2
{
public partial class Form1 : Form
{
PGPLib pgp = new PGPLib();
public Form1()
{
InitializeComponent();
}
private void encryptButton_Click(object sender, EventArgs e)
{
string testingstring = pgp.EncryptString(testTextBox.Text, new FileInfo(@"c:\TCkeyPublic.txt"));
encryptedtextTextBox.Text = testingstring;
}
private void decryptButton_Click(object sender, EventArgs e)
{
try
{
String plainString = pgp.DecryptString(encryptedtextTextBox.Text,
new FileInfo(@"c:\TCkeyPrivate.txt"), passphraseTextBox.Text);
decryptedtextTextBox.Text …Run Code Online (Sandbox Code Playgroud)