It broke my brain trying to read the explanations and definitions... and the code is very primitive.
What is Hash/Hashing?
Hash is used to encrypting the password, emails, address or other information must be hidden or secured.
How the receiver and the sender get the key to unhash?
If both parties make some transaction they the sender already sent the key to the receiver so they can get the information easily.
What are the benefits of hashing?
Hashing is good to avoid from the hackers because the only one can open the code is the receiver and the hacker takes time to decode the hash.
Introduction to System.
1. Click generate. - the system will automatically create a random letter and number.
2. Click Encrypt. - to make it encrypted. The sender will send the encrypted message to the receiver.
3. Click Decrypt. -to make decrypted. The receiver uses the key to received and open the message.
char[] codes = "abcdefghijklmnopqrstuvwzyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToArray();
string output;
void generateKey(int gkey)
{
output = null;
for (int x = 0; x < codes.Length; x++)
{
output += codes[r.Next(0, codes.Length)];
}
t1bx.Text = output;
}
private void B_generate_Click(object sender, RoutedEventArgs e)
{
generateKey(10);
}
static string ComputeSha256Hash(string rawData)
{
// Create a SHA256
using (SHA256 sha256Hash = SHA256.Create())
{
// ComputeHash - returns byte array
byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(rawData));
// Convert byte array to a string
StringBuilder builder = new StringBuilder();
for (int i = 0; i < bytes.Length; i++)
{
builder.Append(bytes[i].ToString("x2"));
}
return builder.ToString();
}
}
static string ComputeSha256Hash2(string rawData)
{
// Create a SHA256
using (SHA256 sha256Hash = SHA256.Create())
{
// ComputeHash - returns byte array
byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF32.GetBytes(rawData));
// Convert byte array to a string
StringBuilder builder = new StringBuilder();
for (int i = 0; i < bytes.Length; i++)
{
builder.Append(bytes[i].ToString("x2"));
}
return builder.ToString();
}
}
private void B_hash_Click(object sender, RoutedEventArgs e)
{
txtbx_hash.Text = ComputeSha256Hash(output);
}
private void B_decrypt_Click(object sender, RoutedEventArgs e)
{
txtbx_dec.Text = output;
}
Ps. This is came to my knowledge and understanding I hope I help you a lot. Here is the project file if you want to test
Click here to download the file[This will direct to google drive].
Is it a bit cynical to think that this is:
a. an attempt to gain merits by trying to look clever/knowledgeable
b. an attempt to spread malware
c. both