private void Salsa20Decrypt(object sender, TextChangedEventArgs e) { string keyText = Salsa20Key.Text; string nonceText = Salsa20Nonce.Text; string encryptedText = Salsa20Encrypted.Text; GetTrimmedBase64(ref encryptedText); // if (encryptedText.Length != 0) // { // encryptedText = encryptedText.Remove(4 * (encryptedText.Length / 4)); // } if (keyText != string.Empty && nonceText != string.Empty && encryptedText != string.Empty && encryptSalsa20) { encryptSalsa20 = false; byte[] key = Encoding.UTF8.GetBytes(keyText); byte[] nonce = Encoding.UTF8.GetBytes(nonceText); //byte[] text = Encoding.ASCII.GetBytes(encryptedText); byte[] text = Convert.FromBase64String(encryptedText); Salsa20.Encrypt(key, nonce, text, selectedSalsa20Method); Salsa20Clear.Text = Convert.ToBase64String(text); encryptSalsa20 = true; } }
private void Salsa20Encrypt() { string keyText = Salsa20Key.Text; string nonceText = Salsa20Nonce.Text; string clearText = Salsa20Clear.Text; GetTrimmedBase64(ref clearText); if (keyText != string.Empty && nonceText != string.Empty && clearText != string.Empty && encryptSalsa20) { encryptSalsa20 = false; byte[] key = Encoding.UTF8.GetBytes(keyText); byte[] nonce = Encoding.UTF8.GetBytes(nonceText); byte[] text = Convert.FromBase64String(clearText); Salsa20.Encrypt(key, nonce, text, selectedSalsa20Method); Salsa20Encrypted.Text = Convert.ToBase64String(text); encryptSalsa20 = true; } }