I'm trying to figure out how to encrypt something with a null cipher such as if someone typed "hi", it would put 1 random character in front of 'h' and inbetween 'h' and 'i' and after 'i'.
so I could do something like this:
Expand|Select|Wrap|Line Numbers
- int main (int argc, char *argv[], char **env)
- {
- int c , count = 1;//atoi(argv[1]) ;
- srand(time(NULL)) ;
- c = rand() % 94 ;
- c += 32 ;
- char b;
- cout.put( c = (32 + rand() % 94) ) ;
- b = cin.get();
- cout.put(b);
- cout.put( c = (32 + rand() % 94) ) ;
- b = cin.get();
- cout.put(b);
- cout.put( c = (32 + rand() % 94) ) ;
- }
I thought I could do something like this (see below), but I know my condition for the loop is wrong and I have no idea what condition I should put in the do while loop.
Expand|Select|Wrap|Line Numbers
- int main (int argc, char *argv[], char **env)
- {
- int c , count = atoi(argv[1]) ;
- srand(time(NULL)) ;
- c = rand() % 94 ;
- c += 32 ;
- char b;
- do
- {
- for (int i = 1; i <= count; i++)
- cout.put( c = (32 + rand() % 94) ) ;
- b = cin.get();
- cout.put(b);
- } while (!cin.eof());
- }