Use a one-time pad. End of story. It's simple and it's unbreakable if you use it once. Also, never use rand() etc. for encryption. Use your own algorithm for randomness you can verify. If you really want to use rand(), don't, use the C++11 equivalent, uniform_int_distribution.