private SecureUTF8String hashTheData ( SecureUTF8String masterPassword , SecureUTF8String data , Account account ) throws Exception { final SecureUTF8String output = new SecureUTF8String ( ) ; final SecureUTF8String secureIteration = new SecureUTF8String ( ) ; SecureUTF8String intermediateOutput = null ; int count = 0 ; final int length = account . getLength ( ) ; try { while ( output . size ( ) < length ) { if ( count == 0 ) { intermediateOutput = runAlgorithm ( masterPassword , data , account ) ; } else { // add ye bit'o chaos secureIteration . replace ( masterPassword ) ; secureIteration . append ( NEW_LINE ) ; secureIteration . append ( new SecureCharArray ( Integer . toString ( count ) ) ) ; intermediateOutput = runAlgorithm ( secureIteration , data , account ) ; secureIteration . erase ( ) ; } output . append ( intermediateOutput ) ; intermediateOutput . erase ( ) ; count ++ ; } } catch ( Exception e ) { output . erase ( ) ; throw e ; } finally { if ( intermediateOutput != null ) intermediateOutput . erase ( ) ; secureIteration . erase ( ) ; } return output ; }
Intermediate step of generating a password . Performs constant hashing until the resulting hash is long enough .