Code example for UndeclaredThrowableException

0
            hmac = Mac.getInstance(crypto);
            SecretKeySpec macKey = new SecretKeySpec(keyBytes, "RAW");
            hmac.init(macKey);
            return hmac.doFinal(text);
        } catch (GeneralSecurityException gse) {
            throw new UndeclaredThrowableException(gse);
        } 
    } 
 
    /** 
     * This method converts HEX string to Byte[] 
     *  
     * @param hex 
     *            the HEX string 
     *  
     * @return A byte array 
     */ 
    private static byte[] hexStr2Bytes(String hex) {
        // Adding one byte to get the right conversion 
        // values starting with "0" can be converted 
        byte[] bArray = new BigInteger("10" + hex, 16).toByteArray();