[convert any format data into binary code]

for example [white.gif] into code like this [0x474946383961B400B400F7FF00B591DBC2C2C2DAEDFFCEE7FF7DA9FFB3CCE6999999B3B3CCB2CCCCB692B6E9E9E96699CC666666DDDDDDCF bla bla....]

Recommended Answers

All 2 Replies

What you probably want is a Hex Editor, which will read any file and display the data in hexadecimal,the format you've shown you want, and in ASCII. A good one will let you export the data as hexadecimal to a text file.

If something is stored on a harddisk, then it is already represented in binary. A harddisk (or any other traditional storage like cd's, dvd's, usb sticks, tapes, etc) only implements a list of 1's and 0's. Everything must be written in terms of that in order to be stored on the disk.

Simularely, anything represended in RAM is also represented as 1's and 0's.

If you wanted to write a program to take a file and produce it's binary representation in ASCII, then you can do so by loading the contents of the file into memory, converts each byte into it's binary representation in binary. This can be done by dividing by the radex and checking for the remainder 8 times (assuming that each byte is 8 bits long).

However in your first post, you gave an example of the hexidecimal representation in ASCII. Again, this can be converted using the same proccess (but by dividing by 16 and checking remainder twice. Note that 2^4=16, so you can just look at the nibbles to convert from binary to a hexidecimal representation as well.).

Though as mentioned, you can always use a hex editor (which is easy enough to convert to binary in your head anyways).

Ps. If your looking for a way to represend a binary file in ASCII, it would be more efficient to use ASCII85 representation instead, or more commonly, BASE64.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.