title: Draw a byte array in a image control
body: <p>Is there anyway to convert a byte array to an image and display it directly in an image control without saving it on the disk?</p>
  
  <p>Here is the code a I have developed so far:</p>
  
  <pre><code>    protected void btnShow_Click(object sender, System.EventArgs e)
      {
          Byte[] blobEncryptedImage = Signature.Get(txSaleGUID.Text);
          Crypto crypto = new Crypto("mypass");
          Byte[] decryptedImage = Encoding.ASCII.GetBytes(crypto.Decrypt(blobEncryptedImage));
  
          MemoryStream ms = new MemoryStream(decryptedImage);
          Image img = Image.FromStream(ms);
          //Image1.ImageUrl = System.Drawing.Image.FromStream(ms);
      }
  
      public static Image byteArrayToImage(byte[] data)
      {
          using (System.IO.MemoryStream ms = new System.IO.MemoryStream(data))
          {
              return new System.Drawing.Bitmap(Image.FromStream(ms));
          }
      }
  </code></pre>
  
  <p><strong>Update 1</strong></p>
  
  <p>this is my crypto class:</p>
  
  <pre><code>    public class Crypto
  {
      private ICryptoTransform rijndaelDecryptor;
      // Replace me with a 16-byte key, share between Java and C#
      private static byte[] rawSecretKey = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  
      public Crypto(string passphrase)
      {
          byte[] passwordKey = encodeDigest(passphrase);
          RijndaelManaged rijndael = new RijndaelManaged();
          rijndaelDecryptor = rijndael.CreateDecryptor(passwordKey, rawSecretKey);
      }
  
      public string Decrypt(byte[] encryptedData)
      {
          byte[] newClearData = rijndaelDecryptor.TransformFinalBlock(encryptedData, 0, encryptedData.Length);
          return Encoding.ASCII.GetString(newClearData);
      }
  
      public string DecryptFromBase64(string encryptedBase64)
      {
          return Decrypt(Convert.FromBase64String(encryptedBase64));
      }
  
      private byte[] encodeDigest(string text)
      {
          MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
          byte[] data = Encoding.ASCII.GetBytes(text);
          return x.ComputeHash(data);
      }
  }
  </code></pre>
  
  <p>Could anyone give a clue?</p>