fingerprint

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: May 9, 2019 License: AGPL-3.0 Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(haystack []Fingerprint, needle Fingerprint) bool

Contains returns true if the given needle (Fingerprint) is present in the given haystack, or false if not.

Types

type Fingerprint

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

Fingerprint represents a 20-character OpenPGP fingerprint.

func FromBytes

func FromBytes(bytes [20]byte) Fingerprint

FromBytes takes 20 bytes and returns a Fingerprint.

func MustParse

func MustParse(fp string) Fingerprint

MustParse takes a string and returns a Fingerprint. If the string is not a valid fingerprint (e.g. 40 hex characters) it will log.Panic.

func Parse

func Parse(fp string) (Fingerprint, error)

Parse takes a string and returns a Fingerprint. Accepts fingerprints with spaces, uppercase, lowercase etc.

func (Fingerprint) Bytes

func (f Fingerprint) Bytes() [20]byte

func (Fingerprint) Hex

func (f Fingerprint) Hex() string

Hex return the fingerprint as uppercase hex (20 bytes, 40 characters) without spaces, for example: `AB01AB01AB01AB01AB01AB01AB01AB01AB01AB01`

func (Fingerprint) IsSet

func (f Fingerprint) IsSet() bool

IsSet returns whether the fingerprint has been parsed correctly, and therefore is set

func (Fingerprint) MarshalText added in v1.0.0

func (f Fingerprint) MarshalText() ([]byte, error)

MarshalText implements encoding.TextUnmarshaler, converting a Fingerprint into bytes for encoders like JSON, TOML etc.

func (Fingerprint) String

func (f Fingerprint) String() string

String return a human-friendly version of the fingerprint, which should be a 40 character hex string. `AB01 AB01 AB01 AB01 AB01 AB01 AB01 AB01 AB01 AB01` String() returns the fingerprint in the "human friendly" format, for example `AB01 AB01 AB01 AB01 AB01 AB01 AB01 AB01 AB01 AB01`

func (*Fingerprint) UnmarshalText added in v1.0.0

func (f *Fingerprint) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler which can parse (unmarshal) a textual version of itself. It allows JSON / toml etc decoders to create a Fingerprint from a string.

func (Fingerprint) Uri

func (f Fingerprint) Uri() string

Uri returns the uppercase hex fingerprint prepended with `OPENPGP4FPR:`, as implemented by OpenKeychain: https://github.com/open-keychain/open-keychain/issues/1281#issuecomment-103580789 for example: `OPENPGP4FPR:AB01AB01AB01AB01AB01AB01AB01AB01AB01AB01`

Jump to

Keyboard shortcuts

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