using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; using System.Security.Cryptography; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button2_Click(object sender, EventArgs e) { RSACryptoServiceProvider myrsa = new RSACryptoServiceProvider(); System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); openFileDialog1.Title = "Insert Image"; openFileDialog1.ShowDialog(); openFileDialog1.Filter = "JPEG Images|*.jpg|GIF Images|*.gif"; object r = new object(); EventArgs en = new EventArgs(); string s1 = richTextBox1.Text; string s2 = richTextBox2.Text; string s3 = richTextBox3.Text; string Chosen_File = ""; Chosen_File = openFileDialog1.FileName; pictureBox1.Image = Image.FromFile(Chosen_File); byte[] byteData = imageToByteArray(pictureBox1.Image); string ToS1 = byteData.ToString(); Byte[] newdata = encoding.GetBytes(ToS1); Byte[] encrypted = myrsa.Encrypt(newdata, false); for (int i = 0; i < encrypted.Length; i++) richTextBox4.Text += encrypted[i].ToString(); Byte[] decrypted = myrsa.Decrypt(encrypted, false);//decrypt pictureBox2.Image = byteArrayToImage(decrypted); } public byte[] imageToByteArray(System.Drawing.Image imageIn) { MemoryStream ms = new MemoryStream(); imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); return ms.ToArray(); } public Image byteArrayToImage(byte[] byteArrayIn) { Stream ms = new MemoryStream(byteArrayIn); Image returnImage = Image.FromStream(ms); return returnImage; } } }The error is in function byteArrayToImage :: Parameter is not valid.