I realized that if the key is chosen randomly from a range that isn't a power of $2$, the one-time-pad leaks information about the plaintext.
For example, if the alphabet was the first 20 naturals, then if you see a 6 in the ciphertext, the plaintext letter must have been within [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 20, 21, 22, 23]
, so it couldn't have been 16
, for example (it couldn't have been 20-23
either, but that's assumed since the alphabet is just the first 20 naturals). However, encrypting and decrypting will work fine.
How can this be exploited in general? If the alphabet is small you can line up all possibilities and try to come up with English words (like coming up with words from phone numbers, possibly?) What about if $n$ is larger?
Unrelated question, given this limitation, why do people use XOR instead of modular addition? Is it just because XOR is faster?