Suppose that I can generate some random variable $X$ that is distributed according to the CDF $F$. If $F$ is continuous then $F(X)$ is uniform $[0,1]$ (can anyone explain this to me).

My question is if $F$ is a CDF of some discrete R.V. $X$, is there some method for generating a uniform $[0,1]$ random variable from $F$ in this case (references or sketch of proofs appreciated)?

This is purely from a probability theoretic perspective (the application is information theoretic cryptography) so I am not interesting in pseudo generation. I am looking for a way to transform $X$ to be a uniform R.V. on $[0,1]$. Thanks in advance.