Giter Site home page Giter Site logo

randomart's Introduction

randomart.py

A script to present BLAKE2b hashes as small ASCII-art pictures, similarly to OpenSSH's randomart.

This allows easier verification by humans but may not be as secure as a bytewise comparison of the digest!

See the paper Hash Visualization: a New Technique to improve Real-World Security for more information on the concept of random art.

The paper The drunken bishop: An analysis of the OpenSSH fingerprint visualization algorithm analyses the OpenSSH implementation in more detail.

Just to be clear: the input is passed into a hash function and its output is then used to generate the ASCII art. By virtue of BLAKE2b being a cryptographically secure hash function, any change in input will lead to a radically different output.

It should also be explicitly noted that my algorithm is similar but not identical to the "drunken bishop" walk of the OpenSSH implementation. The implementation at hand:

  • flips sides at the borders, which turns the field into a torus
  • moves in all possible directions with distance 1, not only diagonally
  • does not mark start (S) and end (E) and uses a different character palette

I have not performed any similar analysis[2][^2] but would expect my implementation to perform no worse.

installation

Install the latest version with pip directly from GitHub:

pip install git+https://github.com/ansemjo/randomart

Or from PyPI:

pip install randomart

usage

The script expects a file in the first positional argument or otherwise simply reads from standard input. It is thus best suitable for usage in a pipe:

echo 'Hello, World!' | randomart.py

There are two flags to control the output:

  • --ascii use only ASCII characters for the box frame
  • --hash - print the computed digest before the randomart picture

Otherwise use randomart.py --help for usage help.

as a library

If you want to use your own hash you can import from random_art.randomart:

from random_art.randomart import draw, drunkenwalk
...

# generate your hash digest
digest = ...

# generate randomart, HASHNAME must be 10 characters
art = draw(drunkenwalk(digest), HASHNAME)
print(art)

randomart's People

Contributors

ansemjo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.