Code example for CipherInputStream

Methods: decodeStream

0
            byte[] iv = new byte[DEFAULT_KEY_LENGTH];
            fis.read(iv);
            Cipher cipher = Cipher.getInstance(ENCRYPT_ALGORYTHM);
            IvParameterSpec ivspec = new IvParameterSpec(iv);
            cipher.init(Cipher.DECRYPT_MODE, getKey(password), ivspec);
            cis = new CipherInputStream(fis, cipher);
        } catch (FileNotFoundException e) {
            Log.e(TAG, e.toString());
        } catch (IOException e) {
            Log.e(TAG, e.toString());
        } catch (NoSuchAlgorithmException e) {
            Log.e(TAG, e.toString());
        } catch (NoSuchPaddingException e) {
            Log.e(TAG, e.toString());
        } catch (InvalidKeyException e) {
            Log.e(TAG, e.toString());
        } catch (InvalidAlgorithmParameterException e) {
            Log.e(TAG, e.toString());
        } 
        if (cis == null) return null;
 
        Bitmap bitmap = null;
        try { 
            bitmap = BitmapFactory.decodeStream(cis, null, null);
        } finally { 
            CloseableUtils.close(cis);
        } 
        return bitmap;
    } 
 
    private static Key getKey(String password) {