card

package
v0.0.0-...-df1f2e6 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2018 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

* Code for generating a printable wallet-sized card containing random password characters.

Index

Constants

View Source
const SeedLength = 32

The number of characters in a seed (after removing dashes and spaces)

Variables

This section is empty.

Functions

func CreateRandomSeed

func CreateRandomSeed() (string, error)

*Generate a new seed from a secure-random source (crypto/rand). The seed has slightly more than 128bits of entropy. It is encoded as 32 A-Z characters. The last two characters are a checksum. Having only A-Z characters makes it easier for users to input their seed (especially on a mobile device). The seed is formatted for easy reading as 8 groups of 4, separated by dashes like so:

ATXK-XGFG-TSPF-JSCG-KEMD-YTBJ-ZWEB-LDVW

The A-Z encoding is one-way. To convert the seed to bytes, hash it with sha256 (uppercase, without the dashes).

This operation should only be done on a trusted computer.

func DigestSeed

func DigestSeed(seed string) ([]byte, error)

* Convert the human readable seed, like "ATXK-XGFG-TSPF-JSCG-KEMD-YTBJ-ZWEB-LDVW", to bytes. Returns an error if the seed is malformed or corrupt. The seed is not case sensitive and dashes and spaces are ignored.

Types

type Card

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

func CreateCard

func CreateCard(digestedSeed []byte, width, height int) (*Card, error)

func (*Card) Erase

func (self *Card) Erase()

func (*Card) String

func (self *Card) String() string

Return \n delimited lines

type Coord

type Coord struct {
	//Horizontal coordinate index, starting at 0
	X int
	//Vertical coordinate index, starting at 0
	Y int

	//The human friendly representation (eg "13W").
	HumanX string
	HumanY string
}

*A coordinate on the card

func MakeCoordinates

func MakeCoordinates(key []byte, count, cardSizeX, cardSizeY int,
	xNameFunc, yNameFunc CoordinateNameFunc) ([]Coord, error)

*Given the 32 byte secret key, deterministically generate `count` X,Y coordinates in the range [0,cardSizeX), [0,cardSizeY). The human friendly names for the coordinates are produced by xNameFunc and yNameFunc

func (Coord) String

func (self Coord) String() string

type CoordinateNameFunc

type CoordinateNameFunc func(index int) string

Jump to

Keyboard shortcuts

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