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))
  • 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.

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.0.0.tar.gz (4.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.0.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pyrandomart-1.0.0.tar.gz
Algorithm Hash digest
SHA256 79b492e7d942adb696f429941c18079a041e6b2bf6109f10e1348f7ebedc974c
MD5 5c5435eca5838a60ba305f4c38edecd0
BLAKE2b-256 c5c9c96ab612824a024876b33f004bb3ee8bc89b4671893bf05b12279d7dc18b

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pyrandomart-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0f64b373d22a7c5b6af23c8a9174dfff5d79b2f093d06c1c05b933c2862f9187
MD5 4b6c98d107801c1fb023034747c13a77
BLAKE2b-256 97a0a38475277237295066821efa5a81825e5feae7158b39a7c594b78f344ff8

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