Qt Code:
int size = f.size(); qDebug() << bytes; //outputs ""MZP qDebug() << bytes.toHex(); //Same output :(To copy to clipboard, switch view to plain text mode
Qt Code:
int size = f.size(); qDebug() << bytes; //outputs ""MZP qDebug() << bytes.toHex(); //Same output :(To copy to clipboard, switch view to plain text mode
What do you expect to read??
You're reading a binary file!
A camel can go 14 days without drink,
I can't!!!
What do you mean?
I want to convert that to hex...
For me this code
Qt Code:
char data [] = { 0xaa, 0x01, 0x00, 0xFF, 0xBA}; qDebug() << ba; qDebug() << ba.toHex();To copy to clipboard, switch view to plain text mode
A camel can go 14 days without drink,
I can't!!!
How is this related to my source?
i get MZP when reading Anscii like wysota said.
But Chris said I have to convert that QBA to hex..which doesn't work...
What doesn't work? What's the point of dumping the whole file to the screen in its hexadecimal form?
Qt Code:
#include <QFile> #include <stdio.h> int main(int argc, char **argv) { int offset = 0; while(!f.atEnd()){ while(offsetStr.size()<8) offsetStr.prepend('0'); printf("0x%s\t", qPrintable(offsetStr)); offset+=16; for(int i=ba.size()-2;i>0;i-=2) { ba.insert(i, ' '); } printf("%s\n", ba.constData()); } return 0; }To copy to clipboard, switch view to plain text mode
Last edited by wysota; 20th April 2011 at 09:23.
Qt 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; }To copy to clipboard, switch view to plain text mode
I want to make that in Qt^^^
And FelixB the loop doesn't stop for me.
it keeps outputting bytes....never stops.
Maybe he wants to encrypt twice as much as he needs to?It's always fun to make a 10MB file out of a 5MB file...
You mean like this?
Qt Code:
To copy to clipboard, switch view to plain text mode
This outputs some strange symbols(I suppose bin. code),but it also beeps and crashes after some secs...
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.
Why doesn't work?
This code
Qt Code:
void Widget::on_openFileButton_clicked() { this, tr ("Open File"), ".", tr ("Executable files (*exe)")); if (!fileName.isEmpty ()) { const int SIZE = 100; int readSize; readSize = (f.size () > SIZE)? SIZE: f.size (); ui->rawDataEdit->setPlainText (ba); ui->hexDataEdit->setPlainText (ba.toHex ()); } }To copy to clipboard, switch view to plain text mode
shows this output when I select a EXE file
imagine1.JPG
A camel can go 14 days without drink,
I can't!!!
Bookmarks