The Math of RSA

Keys in RSA
Choose a pair of prime numbers
Generally, done with random choice followed by probabilistic primality testing.  Call them p and q.  Choose BIG numbers.

Compute a modulus
m = pq

Chose an public exponent
Chose an exponent e such that e < m and e is relatively prime to (p-1)(q-1).  The public key is the pair (m, e).

Choose a private exponent
Chose an exponent d such that (ed-1) is divisible by (p-1)(q-1).  The private key is the key (m,d).

Convert the message to an integer
Easy, just use the ASCII values; the bytes stored on the disk.
Encrypting and Decrypting
cyphertext = plaintext^e mod n
plaintext = cyphertext^d mod n