González Vasco et al. extend the area of application of algorithms for the hidden number problem in 2004. Using this extension and relations among the bits in and binary fraction expansion of x mod p/p, we present a probabilistic algorithm for some trapdoor functions to recover a hidden message when an imperfect oracle is given of predicting most significant bits in hidden message. We show that computing the most significant bit in message encrypted by ElGmal encryption function is as hard as computing the entire plaintext, and so is RSA.