How does your code work? How does it know it has guessed the right password? And is this a bruteforce crack?