Skip to content

Add Textbin Package for Text and Binary Conversion#5

Merged
C-o-m-o-n merged 2 commits intoComon-tech:mainfrom
PB2204:main
Oct 8, 2023
Merged

Add Textbin Package for Text and Binary Conversion#5
C-o-m-o-n merged 2 commits intoComon-tech:mainfrom
PB2204:main

Conversation

@PB2204
Copy link
Copy Markdown
Contributor

@PB2204 PB2204 commented Oct 8, 2023

Summary

This pull request introduces the Textbin package, a Python library that offers text-to-binary and binary-to-text conversion capabilities, as well as JSON-to-base64 and base64-to-JSON encoding and decoding. The package provides a simple and intuitive interface for these common data transformation tasks.

Changes Made

  1. Code Implementation

    • Created the Textbin class with methods for text-to-binary and binary-to-text conversion.
    • Added functions for JSON-to-base64 and base64-to-JSON encoding and decoding.
    • Improved error handling with informative error messages.
    • Added type hints and docstrings for code clarity and usage documentation.
  2. README.md Update

    • Updated the README.md file to include installation instructions for PyPI and GitHub.
    • Provided detailed usage examples for both text and binary conversion and JSON encoding/decoding.
    • Included a "Contributions" section to encourage contributions and credited existing contributors.

Example Usage

Here's how you can use the Textbin package for text and binary conversion:

from textbin.textbin import *

# Convert text to binary
word = "hello"
converted_word = textbin.to_binary(word)
print(converted_word)  # Output: '1101000 1100101 1101100 1101100 1101111'

# Convert binary to text
binary = "1101000 1100101 1101100 1101100 1101111"
converted_binary = textbin.to_text(binary)
print(converted_binary)  # Output: hello

And for JSON encoding and decoding:

from textbin.textbin import json_to_base64, base64_to_json

# Encode a JSON object to base64
word = {"foo": "bar"}
converted_word = json_to_base64(word)
print(converted_word)  # Output: eyJmb28iOiAiYmFyIn0=

# Decode a base64 string to a JSON object
base64_string = "eyJmb28iOiAiYmFyIn0="
converted_binary = base64_to_json(base64_string)
print(converted_binary)  # Output: {'foo': 'bar'}

I hope that this addition to the Python ecosystem proves helpful to users, and I appreciate your consideration of this pull request.

Thank you for your time and attention.

Sincerely,

Pabitra Banerjee
Pabitra Banerjee
PB2204

@C-o-m-o-n
Copy link
Copy Markdown
Member

Thank you

@C-o-m-o-n C-o-m-o-n merged commit 305677e into Comon-tech:main Oct 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants