Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ cryptography
Is it possible to read a binary file such as .exe / .jpg files using C++ and encrypt it using some simple algorithm.
 
The real question is how to read an entire .exe or jpg file into 1 dimensional array and manipulate it.
Posted 12-May-13 6:10am
Comments
Sergey Alexandrovich Kryukov at 12-May-13 13:44pm
   
Is it C++ or C++/CLI? What library do you use for reading JPEG? It be able should to store the data in any stream including memory stream...
—SA
compuknow at 12-May-13 22:12pm
   
I am not using any specific class or function for reading image files. I am just trying to load the entire binary file (jpg / exe) into a 1 dimensional array using commands in fstream.h.
 
But the problem is I am unable to manipulate the array data (elements).
Jochen Arndt at 13-May-13 4:29am
   
It is unclear where you got stuck.
The common steps to read, manipulate and write a file are:
- Get the file size (e.g. using the stat() function)
- Allocate a buffer of that size (type unsigned char [] for binary data)
- Read the file content into that buffer (using read() with iostreams)
- Manipulate the buffer
- Write the buffer to the output file (using write() with iostreams)

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

The simple answer is "yes". You can encrypt any type of file, and a .exe/.dll is just another type of file. You have to beware of obvious things like file access and ownership but it can be done without significant trouble. You typically won't be able to write to system files or files that are currently in use.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 BillWoodruff 330
1 Mathew Soji 309
2 Maciej Los 285
3 DamithSL 225
4 Afzaal Ahmad Zeeshan 207
0 OriginalGriff 6,369
1 Sergey Alexandrovich Kryukov 5,973
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 4,025


Advertise | Privacy | Mobile
Web04 | 2.8.1411019.1 | Last Updated 14 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100