Results 1 to 10 of 18
Hi, I am writing a utility to take in a file with plain text and convert that into binary and outputs the result to another file. I'm thinking of writing ...
- 04-28-2010 #1Just Joined!
- Join Date
- Apr 2010
- Posts
- 9
script to convert from text file to binary
Hi, I am writing a utility to take in a file with plain text and convert that into binary and outputs the result to another file. I'm thinking of writing it in C++ or Python. I was just wondering if there are already built in functions or library that support this already. Any inputs would be appreciated, thanks!
- 04-29-2010 #2Linux User
- Join Date
- Jan 2007
- Location
- cleveland
- Posts
- 452
have you tried "od"?
the sun is new every day (heraclitus)
- 04-29-2010 #3Just Joined!
- Join Date
- Apr 2010
- Posts
- 9
no, not yet, i'm not sure what 'od' is. I tried reading the plain text in and converted to hex -> decimal -> binary. Then write to a file. I had to write functions to do that. I just wonder if there are more efficient ways to do it like some built in functions.
- 04-29-2010 #4It dump files in octal and other formats. Check its manual here.
Originally Posted by chaoses It is amazing what you can accomplish if you do not care who gets the credit.
New Users: Read This First
- 04-29-2010 #5It dump files in octal and other formats. Check its manual here.
Originally Posted by chaoses It is amazing what you can accomplish if you do not care who gets the credit.
New Users: Read This First
- 05-05-2010 #6Just Joined!
- Join Date
- Apr 2010
- Posts
- 9
okay I did a hex dump of my program converting from ascii to binary (seeing only 0s and 1s). It is different from the hex dump of the same file in binary format (seeing junk when viewing). What's the difference between the 2 binary files and how do I convert them back to plain text?
- 05-06-2010 #7
Okay, so what exactly will the conversion do? A text file is simply a file containing no 'un-printable' characters, and typically delimited by some conventional end-of-line character(s). Can you give an example of what some text, say, this post would be as 'binary'? I'm not sure your question is based on any sound understanding of how files are stored, and the representation of of digital data.
--- rod.Stuff happens. Then stays happened.
- 05-06-2010 #8Just Joined!
- Join Date
- Apr 2010
- Posts
- 9
basically, I have a plain text file which contains normal characters like the ones we type here. For example
plaintext.txt contains
hello world
I have another binary file that was told to be converted from plaintext.txt into binary. Its contents can not be viewed by the editors. So that file looks something like this call it file2:
file2 (binary file)
88>¥^QÔA^@^@^@èùÔA^@^
I want to verify if the converted file (file2) is the binary conversion of the plain text file by writing a program to convert the plain text to binary. This file reads in the plain text and convert it into binary and compare the result of the 2. They don't look the same.
So my question is can I use any function to revert file2 to see its contents?
- 05-06-2010 #9
You will need to know the method/algorithm/transformation function that was used to perform the translation. Is this actually some kind of compression or encryption technique? Is it a conversion to a format used by a specific tool? It is unusual for a conversion such as you describe to be performed, especially for arbitrary reason.
--- rod.Stuff happens. Then stays happened.
- 05-06-2010 #10Just Joined!
- Join Date
- Apr 2010
- Posts
- 9
I don't know what method was used, but I was told it did a binary conversion from plain text file to that binary file. I wanted to verify so I wrote a program to do a binary conversion but it didn't match. I need to converted file to feed into something else but until I can verify that it was a binary conversion or whatever. I was just wonder if in fact it was a binary conversion, is there a way to go back from that format to plain text.


Reply With Quote