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.2.tar.gz (7.9 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.2-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pyrandomart-1.1.2.tar.gz
Algorithm Hash digest
SHA256 3d81015205eecf9f0b3177f6b19ba5b7effccd2be2347bd3425faeee3e15acf8
MD5 60170d709d187ad322103367f7c73908
BLAKE2b-256 bfc5ff5003e62cbafa5f2530d8ab62c0cbee72d24a0230b57c6c454ac19ce3e5

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pyrandomart-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a5b6ffec64598e6ac98bd6fbe9fdecbdbdf1603ceaa02b48f2b6e7dd47adde8b
MD5 0e277ca2352d0ddc5d68b0fa28c578df
BLAKE2b-256 b5cc054f510cbf47e18566827714a0ab06efe5db395ea1d4a08ac904a3fd8649

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