One Time Pad Code Program
I was searching for a working implementation of the one time pad encryption method in C, but wasn't able to find one, so I wrote it myself. Wanted to share this in case someone needs it.
One-Time Pad Generator [This is one of the coolest. The one-time pad generator program is rather. In the case of a program, this means that source code must. Cryptomni: A program to encrypt files using the one time pad cipher, a key file is created using the random generator SecureRandom, the source code is open, this.
Feel free to use, distribute, sell or modify the code as you see fit: Everything is explained in the program itself, so I won't go over it again. If you want to add (remove) legal characters, all you have to do is add (remove) them to (from) the tempAlphabetChars array on line 225 and increase (decrease) the alphabetSize on line 10 accordingly (that's the size of the array) and you're done. If you have any suggestions or observations to share, please do. I tried using randomdevice to seed the Mersenne Twister, but apparently there's a bug in MinGW that prevents me from doing that, so I just stuck to using the time (I know it's a horrible idea!). It's not like I'll be encrypting top secret documents anyway (or will I?). At first I was going to just XOR the bits, but soon I found out that that would result in encrypted text containing a ton of unreadable characters, such as NULLs, hearts, etc., so I just resorted to letting the user only use characters that have been given integer values to prevent that sort of thing.

For example, XORing the chars 'a' and 'b' gives a binary value of 00000011, that's the end of text character, console interprets it as a heart, notepad as a superscript L and notepad as an ETX character and I don't want to deal with that. I tried using randomdevice to seed the Mersenne Twister, but apparently there's a bug in MinGW that prevents me from doing that, so I just stuck to using the time (I know it's a horrible idea!). You would still be using MT to generate the numbers, so it doesn't matter much. It'd be better to use std::randomdevice instead, which is supposed to be as close as the system can get to a true randomness source.
It's not like I'll be encrypting top secret documents anyway (or will I?) Then the implementation is pointless. The only people who use OTP use it because they need a mathematical guarantee of uncrackability. I found out that that would result in encrypted text containing a ton of unreadable characters, such as NULLs, hearts, etc. If you want 'human readable' output then just encode the ciphertext in Base64 or even hex. That complexity doesn't belong in the encryption functions.
Like I said, I can't use randomdevice due to a bug (for the record, I'm using the Code::Blocks IDE). On the note of output, thank you for opening my eyes. I will rewrite the program to just XOR it. Could you please explain a few things though?
What do these notations mean: void.data, const void.pad, auto data = ( unsigned char.)data;, auto pad = ( const unsigned char.)pad; Also, how would you go about encoding (and then decoding) the ciphertext in Base64? How would you go about generating the key? A random sequence of 1s and 0s? How can you convert that into chars?
Char a = ( char)01100001; doesn't seem to work. Thank you a lot! EDIT: Found a way to generate 8 random bits and convert them into a char. Ok, I rewrote the whole program ( ) and it works up until a point. It can encrypt/decrypt small pieces of text easily, but when it comes to a wall of text ( for example) it outputs a key and ciphertext files that are both different sizes from each other and the original text (???) and when decrypting it only decrypts like a few first words. Where did I go wrong? Also, on line 11 it doesn't let me change the type of input to unsigned char (maybe that's the problem?).
One Time Pad Code
Oh, and I created my own file extension just to feel cool (and to lower the risk of people messing with the files manually).