(p, q) = gen_rsa_key(); n = p * q; vanity_n = hide_message(n); vanity_q = vanity_n / p; vanity_q = find_next_prime(vanity_q); return (p, vanity_q);If you already have one of the primes and want a particular public key, it's possible to calculate what the other "prime" by division. However, the resulting number is very unlikely to actually be a prime or even an integer.
The trick is that since p and q have a similar size, incrementing q will only change the least-significant half of the modulus. Therefore, simply rounding to an integer and finding a nearby prime to the "ideal" q value will preserve a message hidden in the upper half of the modulus.