Re: Can somebody show how to read bytes?
Quote:
Originally Posted by
"BumbleBee"
.btw,your code makes an infinite loop....
where is that infinite loop? I don't see any...
Re: Can somebody show how to read bytes?
Code:
#include "StdAfx.h"
#include <iostream>
#include <string.h>
using namespace std;
void encrypt_data();
int main()
{
FILE * f;
unsigned char buffer[100];
int n;
f = fopen("C:\\Program Files (x86)\\TeamViewer\\Version6\\TeamViewer.exe", "rb");
if (f)
{
n = fread(buffer, 100, 1, f);
for (int c = 0; c <= 100 ; c++)
{
printf("%.2X ", (int)buffer[c]); //outputs hex!!!!!!
// put an extra space between every 4 bytes
if (c % 4 == 3)
{
printf(" ");
}
// Display 16 bytes per line
if (c % 16 == 15)
{
printf("\n");
}
}
// Add an extra line feed for good measure
printf("\n\n\n");
}
else
{
cout << "error";
}
char a;
cin >> a;
return 0;
}
I want to make that in Qt^^^
And FelixB the loop doesn't stop for me.
Re: Can somebody show how to read bytes?
Quote:
Originally Posted by
"BumbleBee"
btw,your code makes an infinite loop....
There is no infinite loop in my code.
Re: Can somebody show how to read bytes?
Quote:
Originally Posted by
"BumbleBee"
And FelixB the loop doesn't stop for me.
which loop do you mean?
Re: Can somebody show how to read bytes?
it keeps outputting bytes....never stops.
Re: Can somebody show how to read bytes?
Quote:
Originally Posted by
"BumbleBee"
it keeps outputting bytes....never stops.
Maybe try pointing the program to a smaller file?
Re: Can somebody show how to read bytes?
Accually yes.It works with a smaller one.
Thank you for this,could you comment a bit the lines?
Thanks.
Re: Can somebody show how to read bytes?
Quote:
Originally Posted by
"BumbleBee"
Thank you for this,could you comment a bit the lines?
No, I couldn't. It's so trivial there is nothing to comment. If you have specific questions then ask and I'm sure somebody will provide an explanation.
Re: Can somebody show how to read bytes?
Quote:
Originally Posted by
"BumbleBee"
I need to take the hex,in order to encrypt it and save it as a new exe...btw,your code makes an infinite loop....
Why do you want to encrypt the hex (text) version of a binary file? Why not just encrypt the binary version? Converting to text first makes no sense...
Re: Can somebody show how to read bytes?
Maybe he wants to encrypt twice as much as he needs to? :rolleyes: It's always fun to make a 10MB file out of a 5MB file...
Re: Can somebody show how to read bytes?
Quote:
Originally Posted by
squidge
Why do you want to encrypt the hex (text) version of a binary file? Why not just encrypt the binary version? Converting to text first makes no sense...
You mean like this?
Re: Can somebody show how to read bytes?
Quote:
Originally Posted by
"BumbleBee"
Yes, exactlly.
Re: Can somebody show how to read bytes?
This outputs some strange symbols(I suppose bin. code),but it also beeps and crashes after some secs...
Re: Can somebody show how to read bytes?
Do you want to encrypt it or print it? I doubt encrypting it outputs any strange symbols or makes any sounds. This is binary data that is not suitable for printing to a text terminal.
Re: Can somebody show how to read bytes?
Well,crypt it of course,but I want to out put it,to make sure,everything works...and that I will encrypt the data I need.!
Re: Can somebody show how to read bytes?
So encrypt the binary data but output it to a terminal as hex for the before and after.
Re: Can somebody show how to read bytes?
Yup.
Thanks guys for the support,help and sorry for the dump question...:o