Skip to main content

Python library to generate randomart of a bytes string

Project description

pyrandomart

Python library to produce randomart text from a bytes object

This module contains a function to turn a bytes object into a randomart string. see: http://www.dirk-loss.de/sshvis/drunken_bishop.pdf for a description of randomart

Installation

Try either:

pip install pyrandomart

or directly from github

pip install git+https://github.com/aaronm6/pyrandomart.git

Usage

The only function in this package that is useful to import is the last one, 'randomart'. So the recommended usage is:

>>> from pyrandomart import randomart

randomart's call signature and explantion of inputs:

randomart(bStr, header='RSA 4096', footer='SHA256', dims=(9, 17), box='clean')
  • bStr: Bytes object with the hash to be turned into randomart
  • header: Str object to be displayed at the header of the randomart box
  • footer: Str object to be displayed at the footer of the randomart box
  • dims: List or tuple object with dimensions of the randomart box (rows, columns). Dims must be odd ints.
  • box: Describes the characters that make up the border of the randomart box. Input value can be 'clean' or 'simple', or a custom dict object can be provided.

For example, to turn a bytes object consisting of byte values 30 through 60 into randomart and print:

>>> bobj = bytes(range(30,60))
>>> print(randomart(bobj, header='30-60', footer='no hash'))
┏━━━━━[30-60]━━━━━┓
┃@===+o.          ┃
┃XO.*+...         ┃
┃= o o . .        ┃
┃Xo     . .       ┃
┃+Oo     S .      ┃
┃BE.    . o .     ┃
┃=o.     . .      ┃
┃o.               ┃
┃.o.              ┃
┗━━━━[no hash]━━━━┛

Notes

  • The randomart here corresponds to the bytes given in bytes-object bStr. However, often a cryptographic hash is given in the base64 representation of the bytes (e.g. when generating an ssh key). In this case, one can simply import the standard library 'base64' and decode the base64 hash to bytes using base64.b64decode(..) and then pass the result to this randomart function.
  • The number of columns should be large enough to accommodate the header and footer provided. However, this is not explicitly checked, because it's your life. The function will still work if not, but it may look funky.

Project details


Download files

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

Source Distribution

pyrandomart-1.1.1.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyrandomart-1.1.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file pyrandomart-1.1.1.tar.gz.

File metadata

  • Download URL: pyrandomart-1.1.1.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for pyrandomart-1.1.1.tar.gz
Algorithm Hash digest
SHA256 1f35f08ff42dee0a1c8f00db5e89fe7bf549507ba3ab1132b3508705e98672d8
MD5 9056740c080954a627588cec48cc7178
BLAKE2b-256 8d106a61a1a23ca8d30786679630b970110cba09c4d338a439cd19505c578e48

See more details on using hashes here.

File details

Details for the file pyrandomart-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: pyrandomart-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for pyrandomart-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bbe9a2dc736ec883345d809df22a2b28b9b89fceff44f6a7b9c428e841420d30
MD5 8e7bb18cac1d8944ed8552515306f1b0
BLAKE2b-256 30eaafe3c8a3104eb7f37cbb799e77280366994660136a8801fce195fbb48d2e

See more details on using hashes here.

Supported by

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