| | |
Skip BMP header for DES encryption
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2007
Posts: 52
Reputation:
Solved Threads: 0
I am writing an implementation of a DES encryption with a 64 bit plaintext, taken from the pixel information in a BMP file. So I want to skip the header which is 54 bytes, but I am not sure how to do this. This will not be a dynamic project, in the sense that I will always use the same BMP file (as I am producing both a CBC and EBC mode BMP file at the program finish)
If you have no idea what I am talking about, check out this link.
http://www.giac.org/resources/whitep...ography/62.php
So I would like to open the bmp file, skip the first 54 bytes, then consecutively read 8 byte blocks and encrypt them. I just don't know very much about using files in C++.
If you have no idea what I am talking about, check out this link.
http://www.giac.org/resources/whitep...ography/62.php
So I would like to open the bmp file, skip the first 54 bytes, then consecutively read 8 byte blocks and encrypt them. I just don't know very much about using files in C++.
C++ Syntax (Toggle Plain Text)
char buffer[100]; ifstream f; f.open ("pic.bmp", ios::binary); // skip header f.read (buffer, 54); // read 8 bytes into buffer f.read (buffer, 8);
No. Binary mode simply ensures that all file bytes are put into the buffer as is, with no translation whatsoever. Text mode may, depending on the operating system, translate various bytes. For instance, in windows the usual end of line marker is ascii-13 followed by ascii-10. But when read in text mode, all your program sees is the ascii-10.
•
•
Join Date: Oct 2007
Posts: 52
Reputation:
Solved Threads: 0
What I am planning on doing is bitwise operation on the 8 bytes read in from the file. I was thinking of converting the 8 bytes to an integer value, then I remembered ints in windows are 4 bytes. Is a long 8 bytes? And is there a way to convert the 8 bytes read in to the buffer into a long value I can manipulate?
![]() |
Other Threads in the C++ Forum
- Previous Thread: string replace or erase better?
- Next Thread: size of integer array
Views: 541 | Replies: 7
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api array arrays based beginner binary bmp c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete deploy dll download dynamic encryption error file forms fstream function functions game givemetehcodez graph gui homeworkhelp iamthwee ifstream input int java lib library lines linkedlist linker list loop looping loops map math matrix memory microsoft newbie news number output pointer problem program programming project python random read recursion recursive reference return simple sort spoonfeeding stream string strings struct temperature template templates test text text-file tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






