This repository contains two Python programs, namely "Text To Binary" and "Binary To Text." These programs allow you to convert text to binary representation and vice versa.
Author: Shreyas Om
-
Function:
texttobin(file_name)
- This function takes a filename as input, reads the text data from the file, and converts it into a binary representation.
- It then writes the binary data back to the same file, overwriting the existing content.
-
Usage Example:
texttobin("input.txt")
-
Function:
bintotext(file_name)
- This function takes a filename as input, reads binary data from the file (assumed to be space-separated), and converts it into text.
- It then writes the text data back to the same file, overwriting the existing content.
-
Usage Example:
bintotext("output.txt")
-
Clone or download this repository to your local machine.
-
Ensure you have Python installed.
-
Create a text file with the content you want to convert (for Text To Binary) or a binary data file (for Binary To Text).
-
Modify the
file_name
parameter in the function calls with the name of your file. -
Run the Python script with the desired function to perform the conversion.
-
Check the output file for the converted data.
Suppose you have a file named "input.txt" with the text "Hello, World!".
You can use the "Text To Binary Program" as follows:
texttobin("input.txt")
This will overwrite "input.txt" with the binary representation of the text.
To convert it back to text, use the "Binary To Text Program":
python
bintotext("input.txt")
This will restore "input.txt" to its original text content.