spectre

package module
Version: v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2021 License: GPL-3.0 Imports: 6 Imported by: 0

README

Spectre

Go Reference

A Go implementation of spectre.

Currently, it passes a sub-set of the CLI tests.
It also passes the JS sanity check.

This is because I've only implemented v3 of the algorithm and the main pieces.

Implementation breakdown

Generally code wouldn't split across files this liberally. It's done here for ease of reference.

License

GPLv3 - same as the algorithm author

Documentation

Overview

Example

From the website sanity check

s, err := spectre.New("Robert Lee Mitchell", "banana colored duckling")
if err != nil {
	panic(err)
}

pw := s.Site("masterpasswordapp.com")
fmt.Println(pw)
Output:

Jejr5[RepuSosp
Example (Second)

Example with options

scoper := spectre.SimpleScoper{
	Key: "com.jojodev.jolheiser",
}
s, err := spectre.New("Robert Lee Mitchell", "banana colored duckling", spectre.WithScoper(scoper))
if err != nil {
	panic(err)
}

pw := s.Site("jojodev.com",
	spectre.WithScope(spectre.Identification),
	spectre.WithTemplate(spectre.Maximum),
	spectre.WithCounter(2), // Password was leaked, so increment counter (example)
)
fmt.Println(pw)
Output:

Ig^JIcxD!*)TbefJBi6-

Index

Examples

Constants

This section is empty.

Variables

View Source
var DefaultScoper = SimpleScoper{
	Key: "com.lyndir.masterpassword",
}

DefaultScoper is the default Scoper

Functions

This section is empty.

Types

type Option

type Option func(*Spectre)

Option is a Spectre option

func WithScoper

func WithScoper(scoper Scoper) Option

WithScoper assigns a scoper to Spectre

type Scope

type Scope string

Scope is a key scope

const (
	Authentication Scope = "Authentication"
	Identification Scope = "Identification"
	Recovery       Scope = "Recovery"
)

func ParseScope

func ParseScope(s string) (Scope, error)

ParseScope returns a Scope from s

func (Scope) DefaultTemplate

func (s Scope) DefaultTemplate() Template

DefaultTemplate is the default Template for a Scope

type Scoper

type Scoper interface {
	Scope(Scope) string
}

Scoper returns one of the three available scopes

type SimpleScoper

type SimpleScoper struct {
	Key string
}

SimpleScoper is a simple Scoper

func (SimpleScoper) Scope

func (s SimpleScoper) Scope(scope Scope) string

Scope fulfills Scoper

type SiteOption

type SiteOption func(*options)

SiteOption is an option for Spectre.Site

func WithCounter

func WithCounter(c int) SiteOption

WithCounter specifies a counter

func WithScope

func WithScope(s Scope) SiteOption

WithScope specifies a Scope

func WithTemplate

func WithTemplate(t Template) SiteOption

WithTemplate specifies a Template

type Spectre

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

Spectre is a spectre client

func New

func New(name, secret string, opts ...Option) (s *Spectre, err error)

New returns a Spectre client

func (*Spectre) Site

func (s *Spectre) Site(siteName string, opts ...SiteOption) string

Site returns a site password based on Options

type Template

type Template string

Template is a template type

const (
	Maximum Template = "Maximum"
	Long    Template = "Long"
	Medium  Template = "Medium"
	Short   Template = "Short"
	Pin     Template = "PIN"
	Name    Template = "Name"
	Phrase  Template = "Phrase"
	Basic   Template = "Basic"
)

func ParseTemplate

func ParseTemplate(s string) (Template, error)

ParseTemplate parses a Template from s

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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