I am not familiar with correct ways of doing this but one thing in the code seems open to question. When you get a PIN back that is not 4 digits you push it onto
. Do you still want to go on with this invalid PIN to check it's digits against the
hash or should you break out of the loop? As I said, I don't know what is correct but it is something to consider.