1
Answer

Encryption/Decryption not working

dylan

dylan

14y
1.6k
1
This code isnt giving me the correct text decrypted...
 private void Encrypt(object sender, EventArgs e)
{
string keystring = Key.Text.Trim();
byte[] key = Encoding.Unicode.GetBytes(keystring);
byte[] input = Encoding.Unicode.GetBytes(EnterText.Text);
string returnstring = "";
int keyindex = 0;
int counter = 0;
foreach (byte CHAR in input)
{
returnstring += (char)(CHAR + 10);
keyindex++;
counter++;
}
Return.Text = returnstring;
}

private void Decrypt(object sender, EventArgs e)
{
string keystring = Key.Text.Trim();
byte[] key = Encoding.Unicode.GetBytes(keystring);
byte[] input = Encoding.Unicode.GetBytes(EnterText.Text);
string returnstring = "";
int keyindex = 0;
int counter = 0;
foreach (byte CHAR in input)
{
returnstring += (char)(CHAR - 10);
keyindex++;
counter++;
}
Return.Text = returnstring;
}

Answers (1)