Code example for InvalidKeySpecException

Methods: printStackTrace

0
        try { 
            pbeKey = (PBEKey) factory.generateSecret(pwKey);
            byte[] pbkdfKey = pbeKey.getEncoded();
            return pbkdfKey;
        } catch (InvalidKeySpecException e) {
            e.printStackTrace();
        }              
        return null; 
    } 
     
    public static byte[] getRandomSalt() { 
        SecureRandom random = new SecureRandom();
        byte[] saltBytes = new byte[SALT_LEN];
        random.nextBytes(saltBytes);
        return saltBytes;  
    } 
     
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE