title: Convert byte to fileinputstream
body: <p>is there a way i can convert my byte file into fileinputstream so i can decrypt it before i convert it to bitmap. i have tried to change it to fileinputstream and then again but it doesn't seem to work. </p>
  
  <pre><code> ParseFile fileObject = (ParseFile) object.get("ImageFile");fileObject.getDataInBackground(new GetDataCallback() {
  
      public void done(byte[] data, ParseException e) {
           if (e == null) {
            Log.d("test",
            "We've got data in data.");
             FileInputStream data1 = new FileInputStream(data);
             // Decode the Byte[] into 
            // Bitmap
             Bitmap bmp = BitmapFactory.decodeByteArray(decrypt(key, data), 0, data.length);
            // Get the ImageView from
            // main.xml
             ImageView imgFile = (ImageView) findViewById(R.id.image);
  
             // Set the Bitmap into the
             // ImageView
             imgFile.setImageBitmap(bmp);
  
            // Close progress dialog
             progressDialog.dismiss();
  </code></pre>
  
  <p>my decrypt class takes byte and fileinputstream as parameters</p>
  
  <p>private byte[] decrypt(byte[] skey, FileInputStream fis){</p>
  
  <pre><code>    SecretKeySpec skeySpec = new SecretKeySpec(skey, "AES");
      Cipher cipher;
      byte[] decryptedData=null;
      CipherInputStream cis=null;
      try {
          cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
          cipher.init(Cipher.DECRYPT_MODE, skeySpec, new IvParameterSpec(iv));
          // Create CipherInputStream to read and decrypt the image data
          cis = new CipherInputStream(fis, cipher);
          // Write encrypted image data to ByteArrayOutputStream
          ByteArrayOutputStream buffer = new ByteArrayOutputStream();
          byte[] data = new byte[2048];
          while ((cis.read(data)) != -1) {
              buffer.write(data);
          }
          buffer.flush();
          decryptedData=buffer.toByteArray();
      }catch(Exception e){
          e.printStackTrace();
      }
      finally{
          try {
              fis.close();
              cis.close();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
      }
      return decryptedData;
  }
  </code></pre>