There may be several reasons for this issue
1)For example if you wrote the code that is going to make changes to str2 variable after the if-else-end, this might change the output of the isKey function when you run it
2)if the hasher function output is not same when executing it multiple times with the same input
if above statements cannot resolve the issue, then try debugging using the breakpoints. We need some more information about the code in order to reproduce and further investigate the issue
Refer to this for more information.