I've been wanting to create a encrypt decrypt program for a while now and basically I would like to hook up 3 text boxes together with one being text to encrypt. the encrypted code, and the hash used to encrypt the text. so if the program is restarted you can input the hash and the encrypted text to decrypt. Here's what I've got far:
我一直想要创建一个加密解密程序一段时间,基本上我想连接3个文本框和一个正在加密的文本。加密代码和用于加密文本的哈希。因此,如果程序重新启动,您可以输入哈希值和加密文本进行解密。这就是我所拥有的:
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.Security.Cryptography;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("This Program was created by Ashar Ahmed. You may not redistibute this work without explicit premission from its creator. \r\n\r(C) 2015 All Rights Reserved to Ashar Ahmed Industries LLC.");
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
}
private void richTextBox2_TextChanged(object sender, EventArgs e)
{
}
private void richTextBox3_TextChanged(object sender, EventArgs e)
{
}
}
Please help me
请帮我
1 个解决方案
#1
Just to clear things up, you do not use a hash to encrypt. You use an encryption algorithm. A hash is used when you don't need to decrypt, such as when storing a password in the database (you check by hashing their attempt and comparing the two). Before you begin playing with encryption and decryption, I would recommend that you figure out how to get text from a textbox to a string, as well as some other C# and .NET basics. From here, I would recommend you look into System.Security.Cryptography
to figure out how to implement different kinds of encryption. I would also recommend that you use a combo box for choosing the encryption type, as each encryption type will have to hit a different method (or parameter to one method). If you had meant to use a hash algorithm, CryptoConfig.CreateFromName("").ComputeHash(bytes)
will do the trick, and you pass in a string for the hashing type. Keep in mind, you cannot decrypt a hash. Also, you spelled redistribute and permission wrong in your MessageBox.Show
.
只是为了清理,你不要使用哈希来加密。您使用加密算法。当您不需要解密时使用哈希,例如在数据库中存储密码时(通过散列他们的尝试并比较两者来检查)。在开始使用加密和解密之前,我建议您弄清楚如何将文本从文本框中获取到字符串,以及其他一些C#和.NET基础知识。从这里开始,我建议您查看System.Security.Cryptography以了解如何实现不同类型的加密。我还建议您使用组合框来选择加密类型,因为每种加密类型都必须使用不同的方法(或一个方法的参数)。如果您打算使用哈希算法,CryptoConfig.CreateFromName(“”)。ComputeHash(bytes)将完成这一操作,并为散列类型传入一个字符串。请记住,您无法解密哈希。此外,您在MessageBox.Show中拼写重新分配和权限错误。
#1
Just to clear things up, you do not use a hash to encrypt. You use an encryption algorithm. A hash is used when you don't need to decrypt, such as when storing a password in the database (you check by hashing their attempt and comparing the two). Before you begin playing with encryption and decryption, I would recommend that you figure out how to get text from a textbox to a string, as well as some other C# and .NET basics. From here, I would recommend you look into System.Security.Cryptography
to figure out how to implement different kinds of encryption. I would also recommend that you use a combo box for choosing the encryption type, as each encryption type will have to hit a different method (or parameter to one method). If you had meant to use a hash algorithm, CryptoConfig.CreateFromName("").ComputeHash(bytes)
will do the trick, and you pass in a string for the hashing type. Keep in mind, you cannot decrypt a hash. Also, you spelled redistribute and permission wrong in your MessageBox.Show
.
只是为了清理,你不要使用哈希来加密。您使用加密算法。当您不需要解密时使用哈希,例如在数据库中存储密码时(通过散列他们的尝试并比较两者来检查)。在开始使用加密和解密之前,我建议您弄清楚如何将文本从文本框中获取到字符串,以及其他一些C#和.NET基础知识。从这里开始,我建议您查看System.Security.Cryptography以了解如何实现不同类型的加密。我还建议您使用组合框来选择加密类型,因为每种加密类型都必须使用不同的方法(或一个方法的参数)。如果您打算使用哈希算法,CryptoConfig.CreateFromName(“”)。ComputeHash(bytes)将完成这一操作,并为散列类型传入一个字符串。请记住,您无法解密哈希。此外,您在MessageBox.Show中拼写重新分配和权限错误。