dylan

dylan

  • NA
  • 1
  • 1.9k

Encryption/Decryption not working

Nov 11 2010 4:07 AM
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)