randomart

package module
v0.0.0-...-e4f829a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2024 License: MIT Imports: 4 Imported by: 0

README ΒΆ

randomart

Visual fingerprint hash (e.g. "randomart") library for Go.

Implements the "drunken bishop" algorithm from OpenSSH, with added support for arbitrary grid size and tilesets.

Output formats

Examples of rendering the same data with different settings.

OpenSSH compatible

Dimensions: 17x9, Tileset: randomart.SSHTiles, Armor: true

+-----------------+
|    .+.          |
|      o.         |
|     .. +        |
|      Eo =       |
|        S + .    |
|       o B . .   |
|        B o..    |
|         *...    |
|        .o+...   |
+-----------------+
Spacey emoji

Dimensions: 10x10, Tileset: randomart.Galaxy, Armor: false

πŸŒ’πŸŒ”πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ‘
πŸŒ‘πŸŒ‘πŸŒ”πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ‘
πŸŒ‘πŸŒ’πŸŒ‘πŸŒ’πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ‘
πŸŒ‘πŸŒ‘πŸŒšπŸŒ‘πŸŒ”πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ‘
πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ“πŸŒ‘πŸŒ•πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ‘
πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ“πŸŒπŸŒ”πŸŒ‘πŸŒ’πŸŒ‘
πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ“πŸŒ”πŸŒ”πŸŒ’πŸŒ‘πŸŒ’
πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ“πŸŒ•πŸŒ’πŸŒ’πŸŒ“πŸŒ‘
πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ“πŸŒ”πŸŒ“πŸŒ‘πŸŒ’
πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ‘πŸŒ’πŸŒ”πŸŒ”πŸŒ’πŸŒ’

Examples

  • fcaddr: Fingerprint Filecoin f1 addresses

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

View Source
var (
	// All TileSets bundled with the package.
	BundledTileSets = []TileSet{SSHTiles, GalaxyTiles}

	// Classic OpenSSH randomart tileset, using basic ASCII.
	SSHTiles = TileSet{
		ID:    "openssh",
		Runes: []rune{' ', '.', 'o', '+', '=', '*', 'B', 'O', 'X', '@', '%', '&', '#', '/', '^'},
		Start: 'S',
		End:   'E',
	}

	// A spacey emoji based tileset.
	GalaxyTiles = TileSet{
		ID:    "galaxy",
		Runes: []rune{'πŸŒ‘', 'πŸŒ’', 'πŸŒ“', 'πŸŒ”', 'πŸŒ•', 'πŸͺ', 'πŸŒ–', 'πŸŒ—', '🌘'},
		Start: '🌝',
		End:   '🌚',
	}
)

Functions ΒΆ

func Armor ΒΆ

func Armor(b []byte) []byte

Armor wraps the lines of a rendered output b in a simple ASCII box.

Types ΒΆ

type Board ΒΆ

type Board struct {
	// contains filtered or unexported fields
}

func NewBoard ΒΆ

func NewBoard(x, y int) (*Board, error)

NewBoard initializes a Board of dimensions x, y with a starting position of the center point.

x 0β†’n, y 0↓n.

func (*Board) Render ΒΆ

func (b *Board) Render(t TileSet) []byte

Renders output from the current state of Board b using TileSet t.

func (*Board) Write ΒΆ

func (b *Board) Write(fingerprint []byte) (n int, err error)

Write writes len(p) bytes to the underlying Board. The provided fingerprint will be used to explore the board using the drunken bishop algorithm.

Implements the io.Writer interface. The returned number of bytes will always equal len(fingerprint), and the error will always be nil

type TileSet ΒΆ

type TileSet struct {
	ID string // unique name

	Runes []rune

	Start rune // special rune for the starting position (optional)
	End   rune // special rune for the ending position (optional)

	// If PreventRuneOverflow is true, the last value of Runes will be used for
	// any TileSet.Index(n) where n >= len(Runes). Otherwise, the default
	// behavior will be used which is to wrap around.
	PreventRuneOverflow bool
}

func (TileSet) Index ΒΆ

func (t TileSet) Index(n int) rune

Directories ΒΆ

Path Synopsis
example
fcaddr
Example tool to generate a vizhash from a ⨎ Filecoin $FIL f1 address.
Example tool to generate a vizhash from a ⨎ Filecoin $FIL f1 address.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL