Code example for PBEKeySpec

0
     * @param pass - might be a user-entered key, or one generated by generateMasterKey. 
     * @throws Exception 
     */ 
    public void setPassword(String pass) {
		password = pass;
		pbeKeySpec = new PBEKeySpec(password.toCharArray());
		try { 
		    pbeKey = keyFac.generateSecret(pbeKeySpec);
		    pbeCipher = Cipher
		    .getInstance(algorithm,"BC");
		} catch (InvalidKeySpecException e) {
		    Log.e(TAG,"setPassword(): "+e.toString());
		} catch (NoSuchAlgorithmException e) {
		    Log.e(TAG,"setPassword(): "+e.toString());
		} catch (NoSuchProviderException e) {
		    Log.e(TAG,"setPassword(): "+e.toString());
		} catch (NoSuchPaddingException e) {
		    Log.e(TAG,"setPassword(): "+e.toString());
		} 
    }