This code has been floating around the net for quite a few years - it\'s apparently able to provide a password for decrypting an excel spreadsheet that you don\'t know the p
Just a guess, but it looks to me like Excel tests if the password is valid by running it through some sort of hash function which produces a pretty small range of results and compares it with the hashed value stored.
Presumedly what this function is doing is testing all those values until it finds one that works. Judging by the values used, the hash function produces 2^11*(126-31) different values, all of which can be produced by the values generated in this code.
My analysis assumes this routine works. I haven't tested it.