keygen

package
v0.0.0-...-486496a Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package keygen is a library to generate keys

Index

Constants

View Source
const KeySize = 32

KeySize defines the size of the key

Variables

This section is empty.

Functions

func CalculateProbability

func CalculateProbability(s string, caseSensitive bool) int64

CalculateProbability calculates the probability that a string can be found. Case-insensitive letter matches [a-z] can be found in upper and lowercase combinations, so have a higher chance of being found than [0-9], / or +, or case-sensitive matches.

func HumanizeDuration

func HumanizeDuration(duration time.Duration) string

HumanizeDuration returns a human-readable output of time.Duration

func InvalidSearchMsg

func InvalidSearchMsg(s string) string

InvalidSearchMsg returns the error message the search term contains invalid characters

func IsRegex

func IsRegex(s string) bool

IsRegex returns true if any regex metacharacters (except +) are in the search term

func IsValidRegex

func IsValidRegex(s string) string

IsValidRegex checks the regex has any chance of matching a key

func IsValidSearch

func IsValidSearch(s string) bool

IsValidSearch checks the search does not contain any invalid characters

func NumberFormat

func NumberFormat(n int64) string

NumberFormat returns a number-formatted string, eg: 1,123,456

func Plural

func Plural(s string, v int64) string

Plural returns a Plural of `s` if the value `v` is 0 or > 0

Types

type Cruncher

type Cruncher struct {
	Options
	WordMap map[string]int

	RegexpMap map[*regexp.Regexp]int

	Abort bool // set to true to abort processing
	// contains filtered or unexported fields
}

Cruncher struct

func New

func New(options Options, timeout time.Duration) *Cruncher

New returns a Cruncher

func (*Cruncher) CalculateSpeed

func (c *Cruncher) CalculateSpeed() (int64, time.Duration)

CalculateSpeed returns average calculations per second based on the time per run taken from 2 seconds runtime.

func (*Cruncher) CollectToSlice

func (c *Cruncher) CollectToSlice() []Pair

CollectToSlice will run till all the matching keys were calculated. This can take some time

func (*Cruncher) Find

func (c *Cruncher) Find(cb func(match Pair))

Find will invoke a callback function for each match to support some interactivity or at least feedback

type Key

type Key [KeySize]byte

Key is curve25519 key. It is used by WireGuard to represent public and pre-shared keys.

func (Key) String

func (k Key) String() string

String returns a public key as a string

type Options

type Options struct {
	LimitResults  int
	Threads       int
	CaseSensitive bool
	Cores         int
	Timeout       string
}

Options struct

type Pair

type Pair struct {
	Private string
	Public  string
}

Pair struct

type PrivateKey

type PrivateKey [KeySize]byte

PrivateKey is curve25519 key. It is used by WireGuard to represent private keys.

func (*PrivateKey) Public

func (k *PrivateKey) Public() Key

Public computes the public key matching this curve25519 secret key.

func (*PrivateKey) String

func (k *PrivateKey) String() string

String returns a private key as a string

Jump to

Keyboard shortcuts

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