Here's the idea with a text file, you can do the same thing with audio, video, and static pictures as well though it takes a bit more work:
Code:
#include <stdio.h>
#include <stdlib.h>
static void ensteg ( void );
int main ( void )
{
ensteg();
return EXIT_SUCCESS;
}
void ensteg ( void )
{
FILE *crypt, *mask;
int c, f, x, y;
char bRaw[8], bRev[8];
if ( ( mask = fopen ( "mask.txt", "r" ) ) != NULL &&
( crypt = fopen ( "ensteg.txt", "w" ) ) != NULL ) {
printf ( "Enter a string\n" );
while ( ( c = getchar() ) != EOF ) {
for ( x = 7, y = 0; x >= 0; x--, y++ ) {
while ( ( f = getc ( mask ) ) != (int)' ' )
if ( f == EOF ) rewind ( mask );
else (void)putc ( f, crypt );
/* Break the byte down into bits and
** convert each bit into its char
** equivalent.
*/
bRaw[x] = (char)!!( c & ( 1 << (unsigned)x ) );
bRaw[x] = bRaw[x] % 10 + '0';
bRev[y] = bRaw[x];
/* Place the bit in the text file
*/
if ( bRev[y] == '1' ) fprintf ( crypt, "%c ", f );
else (void)putc ( f, crypt );
}
}
/* Finish reading the mask file and close
*/
while ( ( f = getc ( mask ) ) != EOF ) (void)putc ( f, crypt );
fclose ( mask ), fclose ( crypt );
}
else
printf ( "ERROR: File open failure\n" );
printf ( "Press any key to continue" );
(void)getchar();
}
The nice thing about this program is it's simplicity, each byte in a message is broken down into individual bits and printed as spaces accordingly. One space for binary 0 and two spaces for binary 1; the end result being a file that looks like it was badly formatted.
-Prelude