PasswordHash4j/src/cz/GravelCZLP/PasswordHash/PasswordHashv2.java
public boolean auth(String password, String token) {
		Matcher m = layout.matcher(token); // setup matcher
		if (!m.matches()) { // detect if layout matches
			throw new IllegalArgumentException("Invalid token");
		}
		int iterations = iterations(Integer.parseInt(m.group(1))); // get iterations from token
		byte[] hash = Base64.getUrlDecoder().decode(m.group(2));  // get hash from token 
		byte[] salt = Arrays.copyOfRange(hash, 0, SIZE / 4); // get salt from token
		for (int i = 0; i < pepper.length; i++) { // loop pepper
			char ppr = pepper[i]; // get next pepper
			String passw; // init temporary password
			passw = password + ppr; // add pepper to password
			byte[] check = pbkdf2(passw.toCharArray(), salt, iterations); // hash it
			
			// detect if it matches
			int zero = 0;
		    for (int idx = 0; idx < check.length; ++idx) {
			      zero |= hash[salt.length + idx] ^ check[idx];
		    }
		    if (zero == 0) {
		    	return true;
		    }
		}
		return false;
	}
/**
	  * Detects if user entered in the correct password
	  * @param password the password user entered in
	  * @param token the token of password stored in database
	  * @return true if passwords match
	  */
Detects if user entered in the correct password
@param password the password user entered in
@param token the token of password stored in database
@return true if passwords match
Detects if user entered in the correct password @param password the password user entered in @param token the token of password stored in database @return true if passwords match
public boolean auth(String password, String token) {
		Matcher m = layout.matcher(token); 
		if (!m.matches()) { 
			throw new IllegalArgumentException("Invalid token");
		}
		int iterations = iterations(Integer.parseInt(m.group(1))); 
		byte[] hash = Base64.getUrlDecoder().decode(m.group(2));  
		byte[] salt = Arrays.copyOfRange(hash, 0, SIZE / 4); 
		for (int i = 0; i < pepper.length; i++) { 
			char ppr = pepper[i]; 
			String passw; 
			passw = password + ppr; 
			byte[] check = pbkdf2(passw.toCharArray(), salt, iterations); 
			int zero = 0;
		    for (int idx = 0; idx < check.length; ++idx) {
			      zero |= hash[salt.length + idx] ^ check[idx];
		    }
		    if (zero == 0) {
		    	return true;
		    }
		}
		return false;
	}
public boolean auth ( String password , String token ) { Matcher m = layout . matcher ( token ) ; if ( ! m . matches ( ) ) { throw new IllegalArgumentException ( "Invalid token" ) ; } int iterations = iterations ( Integer . parseInt ( m . group ( 1 ) ) ) ; byte [ ] hash = Base64 . getUrlDecoder ( ) . decode ( m . group ( 2 ) ) ; byte [ ] salt = Arrays . copyOfRange ( hash , 0 , SIZE / 4 ) ; for ( int i = 0 ; i < pepper . length ; i ++ ) { char ppr = pepper [ i ] ; String passw ; passw = password + ppr ; byte [ ] check = pbkdf2 ( passw . toCharArray ( ) , salt , iterations ) ; int zero = 0 ; for ( int idx = 0 ; idx < check . length ; ++ idx ) { zero |= hash [ salt . length + idx ] ^ check [ idx ] ; } if ( zero == 0 ) { return true ; } } return false ; }
Detects if user entered in the correct password
 @param password the password user entered in
 @param token the token of password stored in database
 @return true if passwords match
Detects if user entered in the correct password @param password the password user entered in @param token the token of password stored in database @return true if passwords match
// setup matcher // detect if layout matches // get iterations from token // get hash from token  // get salt from token // loop pepper // get next pepper // init temporary password // add pepper to password // hash it // detect if it matches