943,706 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 699
  • C++ RSS
Jun 3rd, 2009
0

Encrypting Binary

Expand Post »
Is it possible to open a file in binary mode and make an array out of it then to encrypt that information. I guess I should ask how you would start something like that? Thanks
Similar Threads
Reputation Points: 23
Solved Threads: 3
Junior Poster
clutchkiller is offline Offline
181 posts
since Jul 2008
Jun 3rd, 2009
0

Re: Encrypting Binary

Well your question is not quite clear but you can always use fopen command with :
“rb” Open a binary file for reading
“wb” Create a binary file for writing
“ab” Append to a binary file
“rb+“ Open a binary file for read/write
“wb+“ Create a binary file for read/write
“ab+“ Open a binary file for read/write

as modes to manipulate it.For more info try this.
Reputation Points: 485
Solved Threads: 88
Posting Pro
csurfer is offline Offline
564 posts
since Jan 2009
Jun 4th, 2009
0

Re: Encrypting Binary

This helps, but to clarify, instead of taking a string of charecters from a text file and throwing them into an array, is it possible to take that same concept but do it with binary? Thanks
Reputation Points: 23
Solved Threads: 3
Junior Poster
clutchkiller is offline Offline
181 posts
since Jul 2008
Jun 4th, 2009
0

Re: Encrypting Binary

Well if you are using linux then you can always use the meta-characters and the od command to your requirements.Check these out <1> <2>
Reputation Points: 485
Solved Threads: 88
Posting Pro
csurfer is offline Offline
564 posts
since Jan 2009
Jun 4th, 2009
0

Re: Encrypting Binary

Yes, of course it can be done. Same as text.
Moderator
Reputation Points: 3278
Solved Threads: 890
Posting Sage
WaltP is offline Offline
7,718 posts
since May 2006
Jun 4th, 2009
0

Re: Encrypting Binary

>This helps, but to clarify, instead of taking a string of charecters from a text file and throwing
>them into an array, is it possible to take that same concept but do it with binary? Thanks

Yes, but don't expect that you would be able to display them. A binary file is a stream of unformatted character. That is, it is raw and does not follow ASCII standards. Hence your terminal won't be able to display it. But it sure can be dumped into a char array.
C++ Syntax (Toggle Plain Text)
  1. fstream f("asdf.dat");
  2. char* arr=new char[ sizeof file];
  3. f.read(reinterpret_cast<char*>(arr), size of file);
Last edited by siddhant3s; Jun 4th, 2009 at 1:01 am.
Reputation Points: 1486
Solved Threads: 140
Practically a Posting Shark
siddhant3s is offline Offline
816 posts
since Oct 2007
Jun 4th, 2009
0

Re: Encrypting Binary

C++ Syntax (Toggle Plain Text)
  1. char* arr = new char[...];
  2. f.read(reinterpret_cast<char*>(arr), ...
Why reinterpret_cast?..
Reputation Points: 1234
Solved Threads: 347
Postaholic
ArkM is offline Offline
2,001 posts
since Jul 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Global pointer loses its' values
Next Thread in C++ Forum Timeline: DirectX in Visual C++: Help moving a mesh starting from BasicHLSL Tutorial





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC