I'm trying to make my own RSA encryption. I know there are build in methods in C# but I wanted to make my own program because I want to understand how it's done. I think I'm messing up when converting from and to the byte array. If someone could push me in the right direction, that would be great :).
private void btnEncrypt_Click(object sender, EventArgs e)
{
EncryptieModulo = 55;
PublicKey = 27;
var PlainText = Encoding.UTF8.GetBytes(txtPlaintext.Text);
for (int i = 0; i < PlainText.Length; i++)
{
PlainText[i] = (byte)(BigInteger.Pow(PlainText[i], PublicKey) % EncryptieModulo);
}
textBox1.Text = Convert.ToBase64String(PlainText);
}
private void btnDecrypt_Click(object sender, EventArgs e)
{
EncryptieModulo = 55;
PrivateKey = 3;
var CrypText = Convert.FromBase64String(txtCCryptedText.Text);
for (int i = 0; i < CrypText.Length; i++)
{
CrypText[i] = (byte)(BigInteger.Pow(CrypText[i], PrivateKey) % EncryptieModulo);
}
textBox1.Text = Encoding.UTF8.GetString(CrypText);
}