passgen

package
v0.0.0-...-6d938e5 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: LGPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Copyright 2013 Herman Schaaf and Shawn Smith

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

View Source
var HiraganaTable = `` /* 708-byte string literal not displayed */

HiraganaTable maps romaji to hiragana

View Source
var KatakanaTable = `` /* 758-byte string literal not displayed */

KatakanaTable maps romaji to katakana

Functions

func Generate

func Generate(in GenerateInput) (*GenerateOutput, *State, error)

Generate generates random password based on given pattern see README.md for examples of pattern

func InitRomaji

func InitRomaji()

Initialize builds the Hiragana + Katakana trie. Because there is no overlap between the hiragana and katakana sets, they both use the same trie without conflict. Nice bonus!

func KanaToRomaji

func KanaToRomaji(kana string) (romaji string)

KanaToRomaji converts a kana string to its romaji form

func NewRandSource

func NewRandSource() *math_rand.Rand

NewRandSource creates a new source for math/rand that uses more secure crypto/rand

Types

type ArgsParser

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

func (*ArgsParser) Parse

func (p *ArgsParser) Parse(input []rune) ([][]rune, []uint64, error)

type CryptoRandSource

type CryptoRandSource struct{}

CryptoRandSource is a source for math/rand that uses more secure crypto/rand

func (CryptoRandSource) Uint64

func (CryptoRandSource) Uint64() uint64

type Error

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

Error is lexical error struct

func NewError

func NewError(typ ErrorType, pos uint, msg string) *Error

NewError creates a new Error

func ParseSpacedError

func ParseSpacedError(str string) *Error

func (*Error) AppendMsg

func (e *Error) AppendMsg(msg string)

AppendMsg add a message to the beginning of current messages

func (*Error) Error

func (e *Error) Error() string

Error returns error string

func (*Error) Message

func (e *Error) Message() string

func (*Error) PrependMsg

func (e *Error) PrependMsg(msg string)

PrependMsg add a message to the end of current messages

func (*Error) SpacedError

func (e *Error) SpacedError() string

func (*Error) WithMarkLen

func (e *Error) WithMarkLen(markLen int) *Error

type ErrorType

type ErrorType string

ErrorType is the type for lexical error types

const (
	// ErrorSyntax is syntax error type
	ErrorSyntax ErrorType = "syntax"
	// ErrorArg is argument error type
	ErrorArg ErrorType = "argument"
	// ErrorValue is value error type
	ErrorValue ErrorType = "value"
	// ErrorUnknown is unknown error type
	ErrorUnknown ErrorType = "unknown"
)

type GenerateInput

type GenerateInput struct {
	Pattern []rune
}

GenerateInput is struct given to Generate

type GenerateOutput

type GenerateOutput struct {
	Password       []rune
	PatternEntropy float64
}

GenerateOutput is struct returned by Generate

type JustifyArgs

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

type LexType

type LexType func(*State) (LexType, error)

LexType is the type for lex functions

func LexRoot

func LexRoot(s *State) (LexType, error)

LexRoot is the root lex implementation

type RootGenerator

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

RootGenerator is the root Generator implementation

func NewRootGenerator

func NewRootGenerator() *RootGenerator

NewRootGenerator creates a new RootGenerator

func (*RootGenerator) Entropy

func (g *RootGenerator) Entropy(s *State) (float64, error)

Entropy returns the entropy after .Generate() is called

func (*RootGenerator) Generate

func (g *RootGenerator) Generate(s *State) error

Generate generates a password

type SharedState

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

SharedState is the shared part of State

func NewSharedState

func NewSharedState() *SharedState

NewSharedState is factory function for SharedState

func (*SharedState) Copy

func (ss *SharedState) Copy() *SharedState

type State

type State struct {
	*SharedState
	// contains filtered or unexported fields
}

State is lex inputs, output and temp state

func NewState

func NewState(ss *SharedState, pattern []rune) *State

NewState is factory function for State

type Trie

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

Trie is a trie data structure

Jump to

Keyboard shortcuts

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