THIS IS FOR HIDING AN TEXT INFORMATION INTO A BMP IMAGE

// low level file-copy intended for image copying(sender end)//

 

#include<stdio.h>

#include<conio.h>

#include<string.h>

#include<stdlib.h>

#include<fcntl.h>

#include<sys\types.h>

#include<sys\stat.h>

#include<io.h>

 

main (int argc,char *argv[])

{

            clrscr();

            char buffer[512],buffer1[512],buffer2[8],*str;

            int inhandle1,inhandle2,outhandle,bytes,bytes1,i,k=0,h;

            printf("Enter text to be hidden :");

            gets(str);

            int l=strlen(str);

 

            if(argc!=3)

            {

                        puts("\n\t Insufficient arguments");

                        exit(1);

            }

 

            inhandle1=open(argv[1],O_RDONLY|O_BINARY);

            if(inhandle1==-1)

            {

                        puts("\n \t Cannot open file");

                        exit(1);

            }

 

            outhandle=open(argv[2],O_CREAT|O_BINARY|O_WRONLY,S_IWRITE);

            if(outhandle==-1)

            {

                        puts("\n \t Cannot open file");

                        exit(1);

            }

 

            bytes=read(inhandle1,buffer1,54);

                          write(outhandle,buffer1,bytes);

 

            while(1)

            {

                        bytes=read(inhandle1,buffer1,512);

                        for(i=0;i<bytes;i++)

                                    {

                                                for(h=0;h<l;h++)

                                                {

 

                                                if(i%512==0 )

                                                            {

                                                                        buffer[i]=str[h];

                                                            }

                                                else

                                                            buffer[i]=buffer1[i];

                                                }

                                    }

 

                        if(bytes>0)

                                    write(outhandle,buffer,bytes);

                        else

                                    break;

            }

 

            close(inhandle1);

            close(outhandle);

            return(0);

            getch();

}

 

 

 

// low level file-copy intended for text extraction(receiver end)//

 

#include<stdio.h>

#include<conio.h>

#include<string.h>

#include<stdlib.h>

#include<fcntl.h>

#include<sys\types.h>

#include<sys\stat.h>

#include<io.h>

 

main (int argc,char *argv[])

{

            clrscr();

            char buffer[512],buffer1[512],buffer2[8],*str;

            int inhandle1,inhandle2,outhandle,bytes,bytes1,i,h;

 

            if(argc!=3)

            {

                        puts("\n\t Insufficient arguments");

                        exit(1);

            }

            inhandle1=open(argv[1],O_RDONLY|O_BINARY);

            outhandle=open(argv[2],O_CREAT|O_BINARY|O_WRONLY|S_IWRITE);

 

            if(inhandle1==-1)

            {

                        puts("\n \t Cannot open file");

                        exit(1);

            }

 

            //outhandle=open(argv[2],O_CREAT|O_BINARY|O_RDWR,S_IWRITE);

            if(outhandle==-1)

            {

                        puts("\n \t Cannot open file");

                        exit(1);

            }

 

            /*bytes=read(inhandle1,buffer1,54);

                         write(outhandle,buffer,bytes);*/

 

            while(1)

            {

                        bytes=read(inhandle1,buffer1,512);

                        for(i=0;i<bytes;i++)

                                    {

                                                if(i%512==0 )

                                                            {

                                                                        buffer[i]=buffer1[i];

 

                                                            }

                                    }

                         if(bytes>0)

                                    write(outhandle,buffer,bytes);

                        else

                                    break;

             }

 

            close(inhandle1);

            close(outhandle);

 

            inhandle2=open(argv[2],O_RDONLY|O_TEXT);

            if(inhandle2==-1)

            {

                        puts("\n \t Cannot open file");

                        exit(1);

            }

 

            //bytes=read(inhandle2,buffer,54);

                         /*write(outhandle,buffer1,bytes);*/

 

            while(1)

            {

                        bytes=read(inhandle2,buffer,512);

                        for(i=0;i<bytes;i++)

                                    {

                                                *str=buffer[i];

                                                str++;

                                    }

            }

            puts(str);

            close(inhandle2);

            return(0);

            getch();

}

 

 

 BACK TO HOME                                      BACK TO CONTENTS