|
1 | | -# textbin |
| 1 | +# PyTextBin |
2 | 2 |
|
3 | | -**textbin** is a Python package that provides text-to-binary and binary-to-text conversion, as well as JSON-to-base64 and base64-to-JSON encoding and decoding. |
4 | | -See the [documentaion](https://c-o-m-o-n.github.io/textbin/) for more information |
| 3 | +**PyTextBin** is a versatile Python library facilitating seamless conversion between text, binary, JSON, base64, xml and CSV formats with ease.' |
| 4 | +See the [documentaion](https://github.com/Comon-tech/Pytextbin/) for more information |
5 | 5 |
|
6 | 6 |
|
7 | 7 | ## Installation |
8 | 8 |
|
9 | | -You can install **textbin** using pip from PyPI: |
| 9 | +You can install **PyTextBin** using pip from PyPI: |
10 | 10 |
|
11 | 11 | ```bash |
12 | | -pip install textbin |
| 12 | +pip install PyTextBin |
13 | 13 | ``` |
14 | 14 |
|
15 | 15 | Alternatively, you can find the project on GitHub: |
16 | 16 |
|
17 | | -[GitHub Repository](https://github.com/C-o-m-o-n/textbin) |
| 17 | +[GitHub Repository](https://github.com/C-o-m-o-n/PyTextBin) |
18 | 18 |
|
19 | 19 | ## Usage |
20 | 20 |
|
21 | 21 | ### Text and Binary |
22 | 22 |
|
23 | 23 | ```python |
24 | | -from textbin.textbin import * |
| 24 | +# Import everything from textbin |
| 25 | +from pytextbin import * |
25 | 26 |
|
26 | | -# Convert text to binary |
27 | | -word = "hello" |
28 | | -converted_word = textbin.to_binary(word) |
29 | | -print(converted_word) # Output: '1101000 1100101 1101100 1101100 1101111' |
| 27 | +#To begin, create an object from the Textbin() class, which you'll use to access all the methods. |
30 | 28 |
|
31 | | -# Convert binary to text |
32 | | -binary = "1101000 1100101 1101100 1101100 1101111" |
33 | | -converted_binary = textbin.to_text(binary) |
34 | | -print(converted_binary) # Output: hello |
35 | | -``` |
36 | 29 |
|
37 | | -### JSON and Base64 |
| 30 | +# 0) create textbin_obj instance |
| 31 | +textbin_obj = pytextbin.Textbin() |
38 | 32 |
|
39 | | -```python |
40 | | -from textbin.textbin import json_to_base64, base64_to_json |
| 33 | +# 1) convert text to binary |
| 34 | +text = 'hello world' |
| 35 | +converted = textbin_obj.to_binary(text) |
| 36 | +print("to_binary>>", converted) |
| 37 | + |
| 38 | +# 2) convert json data to a base64 string |
| 39 | +json_data = { 'id' : 12 , 'name' : 'Collins' } |
| 40 | +converted = textbin_obj.json_to_base64(json_data) |
| 41 | +print("json_to_base64>>", converted) |
41 | 42 |
|
42 | | -# Encode a JSON object to base64 |
43 | | -word = {"foo": "bar"} |
44 | | -converted_word = json_to_base64(word) |
45 | | -print(converted_word) # Output: eyJmb28iOiAiYmFyIn0= |
| 43 | +base64_data = 'eyJpZCI6IDEyLCAibmFtZSI6ICJDb2xsaW5zIn0=' |
| 44 | +converted = textbin_obj.base64_to_json(base64_data) |
| 45 | +print("base64_to_json>>", converted) |
46 | 46 |
|
47 | | -# Decode a base64 string to a JSON object |
48 | | -base64_string = "eyJmb28iOiAiYmFyIn0=" |
49 | | -converted_binary = base64_to_json(base64_string) |
50 | | -print(converted_binary) # Output: {'foo': 'bar'} |
51 | 47 | ``` |
52 | 48 |
|
53 | 49 | ## Contributions |
54 | 50 |
|
55 | | -Contributions to **textbin** are welcome! You can find the project's GitHub repository and contribute to its development. |
| 51 | +Contributions to **PyTextBin** are welcome! You can find the project's GitHub repository and contribute to its development. |
56 | 52 |
|
57 | 53 | - [GitHub Repository](https://github.com/C-o-m-o-n/textbin) |
58 | 54 |
|
|
0 commit comments