private static byte[] aesDecipher(byte[] encrypted_bytes, byte[] decrypted_bytes) throws UnsupportedCryptoAlgorithmException, InvalidPasswordCipherException {
        if (encrypted_bytes[0] == 0) { // we only process if we understand the encoding scheme.
            Cipher c;
            try {
                c = Cipher.getInstance("AES/CBC/PKCS5Padding");
                c.init(Cipher.DECRYPT_MODE, AESKeyManager.getKey(null), AESKeyManager.getIV(null));
                byte[] decrypted = c.doFinal(encrypted_bytes, 1, encrypted_bytes.length - 1);
                if (decrypted != null) {
                    decrypted_bytes = new byte[decrypted.length - decrypted[0] - 1];
                    System.arraycopy(decrypted, decrypted[0] + 1, decrypted_bytes, 0, decrypted_bytes.length);
                }
            } catch (NoSuchAlgorithmException e) {
                throw (UnsupportedCryptoAlgorithmException) new UnsupportedCryptoAlgorithmException().initCause(e);
            } catch (NoSuchPaddingException e) {
                throw (UnsupportedCryptoAlgorithmException) new UnsupportedCryptoAlgorithmException().initCause(e);
            } catch (InvalidKeyException e) {
                throw (InvalidPasswordCipherException) new InvalidPasswordCipherException().initCause(e);
            } catch (IllegalBlockSizeException e) {
                throw (UnsupportedCryptoAlgorithmException) new UnsupportedCryptoAlgorithmException().initCause(e);
            } catch (BadPaddingException e) {
                throw (UnsupportedCryptoAlgorithmException) new UnsupportedCryptoAlgorithmException().initCause(e);
            } catch (InvalidAlgorithmParameterException e) {
                throw (InvalidPasswordCipherException) new InvalidPasswordCipherException().initCause(e);
            }
        } else {
            throw new InvalidPasswordCipherException();
        }
        return decrypted_bytes;
    }
private static byte [ ] aesDecipher ( byte [ ] encrypted_bytes , byte [ ] decrypted_bytes ) throws UnsupportedCryptoAlgorithmException , InvalidPasswordCipherException { if ( encrypted_bytes [ 0 ] == 0 ) { Cipher c ; try { c = Cipher . getInstance ( "AES/CBC/PKCS5Padding" ) ; c . init ( Cipher . DECRYPT_MODE , AESKeyManager . getKey ( null ) , AESKeyManager . getIV ( null ) ) ; byte [ ] decrypted = c . doFinal ( encrypted_bytes , 1 , encrypted_bytes . length - 1 ) ; if ( decrypted != null ) { decrypted_bytes = new byte [ decrypted . length - decrypted [ 0 ] - 1 ] ; System . arraycopy ( decrypted , decrypted [ 0 ] + 1 , decrypted_bytes , 0 , decrypted_bytes . length ) ; } } catch ( NoSuchAlgorithmException e ) { throw ( UnsupportedCryptoAlgorithmException ) new UnsupportedCryptoAlgorithmException ( ) . initCause ( e ) ; } catch ( NoSuchPaddingException e ) { throw ( UnsupportedCryptoAlgorithmException ) new UnsupportedCryptoAlgorithmException ( ) . initCause ( e ) ; } catch ( InvalidKeyException e ) { throw ( InvalidPasswordCipherException ) new InvalidPasswordCipherException ( ) . initCause ( e ) ; } catch ( IllegalBlockSizeException e ) { throw ( UnsupportedCryptoAlgorithmException ) new UnsupportedCryptoAlgorithmException ( ) . initCause ( e ) ; } catch ( BadPaddingException e ) { throw ( UnsupportedCryptoAlgorithmException ) new UnsupportedCryptoAlgorithmException ( ) . initCause ( e ) ; } catch ( InvalidAlgorithmParameterException e ) { throw ( InvalidPasswordCipherException ) new InvalidPasswordCipherException ( ) . initCause ( e ) ; } } else { throw new InvalidPasswordCipherException ( ) ; } return decrypted_bytes ; }
@param encrypted_bytes
@param decrypted_bytes
@return
@throws UnsupportedCryptoAlgorithmException
@throws InvalidPasswordCipherException