bishopviz
Drunken Bishop algorithm implementation for random ASCII art generation from md5 hashes, and for data visualization from generated art.
Installation
(Recommended) If you have pipx installed:
pipx install bishopviz
Otherwise:
pip install bishopviz
Or, to use the web version, go to https://bishopviz.streamlit.app
Try it
Web App
The web app is the same algorithm, but shows some data visualizations about it.
Go to the website, type anything into the text area, and then do ctrl+Enter.
CLI
A quick demo of the colors and animation:
bishopviz -a 0.1 -C
To specify a file to generate randomart for, add the -f flag and then specify a file path.
To see all of the options of the CLI, run:
bishopviz --help
Features
- md5 hash from a random string or a file
- Implementation of the drunken bishop algorithm to generate randomart
- Various character sets (like texture packs!) for the final graph
- Visualize the algorithm over time via animations and generation count
- (CLI) Graph with colors representing the visit frequency
- (Webapp) Web App with data visualizations from the algorithm
CLI Help Menu
Usage: bishopviz [OPTIONS]
Drunken Bishop algorithm implementation for random ASCII art generation from
md5 hashes.
Options:
-f, --file-feed TEXT Use the contents of any file as the input.
-a, --animate FLOAT Display the algorithm's progress as an animation, with
the specified number of seconds as the interval
between frames.
-c, --charset TEXT Use a different character set for the graph. Options:
ascii, ascii_alt, emoji, emoji2, emoji3, emoji4,
greek, cyrillic, katakana, math, blocks, faces, cars,
plants [default: ascii]
-C, --colors Whether to colorize the output.
-d, --data Open a Streamlit app to run the algorithm and
visualize data.
--no-start-end Don't show the start and end positions on the graph.
-h, --help Show this message and exit.
How It Works
For a better explanation, check out this awesome paper on the topic.
First, an md5 hash is generated from the input (this can be text, an image, video, etc.). This hash is then encoded into 128 bits, and then split into 64 pairs of 2 bits each.
The algorithm generates a 2-dimensional 17x9 matrix and then tracks the position of a "bishop", which starts off in the middle of the matrix.
It will iterate over the byte pairs and move in a certain direction depending on the pair:
| Bit | Direction |
|---|---|
| 00 | Up, Left |
| 01 | Up, Right |
| 10 | Down, Left |
| 11 | Down, Right |
My program, while iterating over the pairs, will track certain variables to then create data visualizations using Streamlit and Plotly.
Technologies/Libraries Used
- Streamlit, to create the web app
- Plotly, to create the graphs
- Pandas, to manipulate the data generated by the algorithm
- Click, for the CLI
- The drunken bishop: An analysis of the OpenSSH fingerprint visualization algorithm by Loss et al. for insights on how the algorithm worked
Metadata
Release files for bishopviz 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| bishopviz-1.0.2.tar.gz | 10.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bishopviz-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.8 kB
Release files / bishopviz-1.0.2.tar.gz
| Download URL | bishopviz-1.0.2.tar.gz |
|---|---|
| Size | 10.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
879090a870b5b42b0a9d9dc63a0291e2e52f5538fe482603a22ddb729f614790
|
|
BLAKE2b-256 checksum How to use checksums |
4d1c2909919d6e45da1a74279a567afdbeb0aae3d71cc26f8082cde7c93cafa4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / bishopviz-1.0.2-py3-none-any.whl
| Download URL | bishopviz-1.0.2-py3-none-any.whl |
|---|---|
| Size | 10.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ac7c54965d7591a9d00c6cd415f4aa8cb449d161ee7bea10e04428022a2b5d44
|
|
BLAKE2b-256 checksum How to use checksums |
2aea5a854d51b653e996a3d1ff4463da7c569148fdcc82fc06f161f445e07c25
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|