base16 is like hexadecimal, but with an alphabet chosen to minimise human transcription errors.
Project description
Base16
A human-readable, compact binary data representation. Base16 is the hexidecimal system with a different character set - chosen to minimize ambiguity between letters. It is useful for high entropy inputs like voucher codes and confirmation codes. By default, when an alphanumeric character outside the base16 character set is decoded it is first replaced with the most similar valid character. The main goal is to minimise user frustration around these types of data input.
Character Set
Hexidecimal | Base16 |
---|---|
0 | A |
1 | B |
2 | C |
3 | D |
4 | E |
5 | G |
6 | H |
7 | K |
8 | P |
9 | R |
a | S |
b | T |
c | W |
d | X |
e | Y |
f | Z |
Usage
Install
pip install base16
Python
>>> import base16
>>> base16.encode(b'Hello, World!')
b'EPHGHWHWHZCWCAKKHZKCHWHECB'
>>> base16.decode(b'EPHGHWHWHZCWCAKKHZKCHWHECB')
b'Hello, World!'
>>> base16.random(16)
b'BABKXPWCBBPZDGPB'
Command Line
> bash16 --encode "Hello, World!"
EPHGHWHWHZCWCAKKHZKCHWHECB
> bash16 --decode "EPHGHWHWHZCWCAKKHZKCHWHECB"
Hello, World!
> base16 --random 32
PKCTPECYBZGGXKRATBCCHGWDDECKCWCA
> echo "some piped data" | base16 --encode
KDHZHXHGCAKAHRKAHGHECAHEHBKEHB
> echo "KDHZHXHGCAKAHRKAHGHECAHEHBKEHB" | base16 --decode
some piped data
Decoding Incorrect Characters
If the user tries to decode a character not included in the base16 character set, we first replace it with the most-likely intended valid character. These replacement characters were chosen from a 1983 study [1] of four male university students' transcription errors. When a more representative study is found, these values can be safely changed later.
Invalid | Valid |
---|---|
0 | D |
1 | T |
2 | Z |
3 | E |
4 | A |
5 | S |
6 | G |
7 | T |
8 | B |
9 | P |
F | E |
I | T |
J | T |
L | E |
M | W |
N | H |
O | D |
Q | D |
U | W |
V | Y |
References
[1] Gupta, S.M. et al., Proceedings of the SIGCHI Conference on Human Factors in Computing Systems, 1983, 83, 144-149
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file base16-0.1.2.tar.gz
.
File metadata
- Download URL: base16-0.1.2.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | de179bc6715bf130f0f06e2b2f6e836bc940b3ac7a9a23aae810fba0904a5940 |
|
MD5 | a5305ac26408e0dc4355f62d33a9c05e |
|
BLAKE2b-256 | c02541a9f24abde71d7e0f8634caf9f37fe58fde8ef8c2d77cc6066b398be55d |
File details
Details for the file base16-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: base16-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78ecbb725a07d4229dc41b0f79b6b1244126111c6c9b451c8c3f1bbfa490ab7c |
|
MD5 | 41a330626ee66a9376eca872445c9950 |
|
BLAKE2b-256 | 993f0e03d45f63a5d4d5a8d477bd019ef7a33f3218c625064615058b42de6729 |