/// Generate both passwords (for the first and the second door) according to the Easter
/// Bunny engineers questionable algorithm.
///
/// The cracking process will continue as long as the given `progress` function return
/// `true`.
///
/// # Errors
///
/// When the password generation failed.
Generate both passwords (for the first and the second door) according to the Easter
Bunny engineers questionable algorithm.

The cracking process will continue as long as the given `progress` function return
`true`.
Generate both passwords ( for the first and the second door ) according to the Easter Bunny engineers questionable algorithm . The cracking process will continue as long as the given ` progress ` function return ` true ` .
pub fn crack<T>(&self, progress: T) -> Result<(Password, Password), String>
                where T: Fn(&Password, &Password) -> bool {
            let mut passwords = (Password::new(), Password::new());
            let mut generator = hashing::InterestingHashFinder::new(&self.door_id).ok_or("OpenSSL error")?;
            while progress(&passwords.0, &passwords.1) {
                let hash_str = generator.next().ok_or("Password generation failure")?;
                let sixth    = hash_str.chars().nth(5).ok_or("Password generation error")?;
                let seventh  = hash_str.chars().nth(6).ok_or("Password generation error")?;
                // First door password:
                // > […] the sixth character in the hash is the next character of the password.
                let position = passwords.0.characters.iter().position(|&ch| ch == UNKNOWN_CHAR);
                if let Some(index) = position {
                    passwords.0.characters[index] = sixth;
                }
                // Second door password:
                // > […] the sixth character represents the position (0-7), and the seventh
                // > character is the character to put in that position.
                // > […] Use only the first result for each position, and ignore invalid positions.
                let index = (sixth as u8 - '0' as u8) as usize;
                if index < PASSWORD_LEN && passwords.1.characters[index] == UNKNOWN_CHAR {
                    passwords.1.characters[index] = seventh;
                }
            }
            Ok(passwords)
        }
pub fn crack < T > ( & self , progress : T ) -> Result < ( Password , Password ) , String > where T : Fn ( & Password , & Password ) -> bool { let mut passwords = ( Password :: new ( ) , Password :: new ( ) ) ; let mut generator = hashing :: InterestingHashFinder :: new ( & self . door_id ) . ok_or ( " " ) ? ; while progress ( & passwords . 0 , & passwords . 1 ) { let hash_str = generator . next ( ) . ok_or ( " " ) ? ; let sixth = hash_str . chars ( ) . nth ( 5 ) . ok_or ( " " ) ? ; let seventh = hash_str . chars ( ) . nth ( 6 ) . ok_or ( " " ) ? ; // First door password: // > […] the sixth character in the hash is the next character of the password. let position = passwords . 0 . characters . iter ( ) . position ( | & ch | ch == UNKNOWN_CHAR ) ; if let Some ( index ) = position { passwords . 0 . characters [ index ] = sixth ; } // Second door password: // > […] the sixth character represents the position (0-7), and the seventh // > character is the character to put in that position. // > […] Use only the first result for each position, and ignore invalid positions. let index = ( sixth as u8 - '0' as u8 ) as usize ; if index < PASSWORD_LEN && passwords . 1 . characters [ index ] == UNKNOWN_CHAR { passwords . 1 . characters [ index ] = seventh ; } } Ok ( passwords ) }
Generate both passwords (for the first and the second door) according to the Easter
Bunny engineers questionable algorithm.
Generate both passwords ( for the first and the second door ) according to the Easter Bunny engineers questionable algorithm .
&self
progress
T
errors
When the password generation failed.
When the password generation failed .