Skip to main content

Convert [Python dictionary | ASCII JSON string] into hexadecimal string.

Project description

hex-json

Convert [python dictionary | ASCII JSON string] into hexadecimal string.
Restore from a hexadecimal string to [python dictionary | ASCII JSON string].
Useful for ethereum transaction data signature.

https://github.com/Sobolev5/hex-json

Install

To install run:

pip install hex-json

Convert and restore dict

from hex_json import hex_serialize, hex_deserialize

d = {"hello": "world"}
hex_s = hex_serialize(d)
print(hex_s) # 7b2268656c6c6f223a22776f726c64227d

d = hex_deserialize(hex_s)
print(d) # {'hello': 'world'}
print(type(d)) # <class 'str'>

Convert and restore ASCII JSON string

from hex_json import hex_serialize, hex_deserialize

s = '{"hello": "world"}'
hex_s = hex_serialize(s)
print(hex_s) # 227b5c2268656c6c6f5c223a205c22776f726c645c227d22

s = hex_deserialize(hex_s)
print(s) # {"hello": "world"}
print(type(s)) # <class 'str'>

Tests

tox

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

hex_json-0.0.2.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file hex_json-0.0.2.1-py3-none-any.whl.

File metadata

  • Download URL: hex_json-0.0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.2

File hashes

Hashes for hex_json-0.0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 292dba7ad7ffe50a3cebcacfa9e8411bd50abe4b1f2a5bb09153872b88d28557
MD5 517ca16e68af3f4932efeaf13ab3a1e8
BLAKE2b-256 081526999c500c84aaa507f1576456c47b1697892e335e694df386d66c17f3ee

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page