Your code is fail on MAP.charAt(Pass.indexOf(alpha.charAt(i)));

Because there is no character in variable Pass, so the return of indexOf is -1.

What do you want from this code ?