Documentation ¶
Overview ¶
Package atoll is a secret generator that makes use of the crypto/rand package to generate cryptographically secure numbers and offer a high level of randomness.
Index ¶
- Constants
- func Keyspace(secret Secret) float64
- func NewPassphrase(length uint64, l list) ([]byte, error)
- func NewPassword(length uint64, levels []Level) ([]byte, error)
- func NewSecret(secret Secret) ([]byte, error)
- func NoList(p *Passphrase, length int)
- func SecondsToCrack(secret Secret) float64
- func SyllableList(p *Passphrase, length int)
- func WordList(p *Passphrase, length int)
- type Level
- type Passphrase
- type Password
- type Secret
Examples ¶
Constants ¶
const ( Lower = Level("abcdefghijklmnopqrstuvwxyz") Upper = Level("ABCDEFGHIJKLMNOPQRSTUVWXYZ") Digit = Level("0123456789") Space = Level(" ") Special = Level("&$%@#|/\\=\"*~^`'.?!,;:-+_(){}[]<>") )
Password level.
Variables ¶
This section is empty.
Functions ¶
func Keyspace ¶ added in v0.3.0
Keyspace returns the set of all possible permutations of the generated key (poolLength ^ keyLength).
On average, half the key space must be searched to find the solution (keyspace/2).
Example ¶
package main import ( "fmt" "github.com/GGP1/atoll" ) func main() { p := &atoll.Password{ Length: 6, Levels: []atoll.Level{atoll.Lower}, Repeat: false, } fmt.Println(atoll.Keyspace(p)) }
Output: 3.089157759999998e+08
func NewPassphrase ¶
NewPassphrase returns a random passphrase.
Example ¶
package main import ( "fmt" "log" "github.com/GGP1/atoll" ) func main() { passphrase, err := atoll.NewPassphrase(5, atoll.NoList) if err != nil { log.Fatal(err) } fmt.Println(passphrase) // Example output: // ynuafnezm hvoq asruso jvoe psiro }
Output:
func NewPassword ¶
NewPassword returns a random password.
Example ¶
package main import ( "fmt" "log" "github.com/GGP1/atoll" ) func main() { password, err := atoll.NewPassword(16, []atoll.Level{atoll.Digit, atoll.Lower}) if err != nil { log.Fatal(err) } fmt.Println(password) // Example output: // ?{{5Rt%r3OrE}7?z }
Output:
func NoList ¶
func NoList(p *Passphrase, length int)
NoList generates a random passphrase without using a list, making the potential attacker work harder.
func SecondsToCrack ¶ added in v0.3.0
SecondsToCrack returns the time taken in seconds by a brute force attack to crack the secret.
It's assumed that the attacker can perform 1 trillion guesses per second.
func SyllableList ¶
func SyllableList(p *Passphrase, length int)
SyllableList generates a passphrase using a syllable list (10,129 long).
func WordList ¶
func WordList(p *Passphrase, length int)
WordList generates a passphrase using a wordlist (18,325 long).
Types ¶
type Passphrase ¶
type Passphrase struct { // List used to generate the passphrase. List list // Words separator. Separator string // Words that will be part of the passphrase. Include []string // Words that won't be part of the passphrase. Exclude []string // Number of words in the passphrase. Length uint64 // contains filtered or unexported fields }
Passphrase represents a sequence of words/syllables with a separator between them.
Example ¶
package main import ( "fmt" "log" "github.com/GGP1/atoll" ) func main() { p := &atoll.Passphrase{ Length: 8, Separator: "&", List: atoll.WordList, Include: []string{"atoll"}, Exclude: []string{"watermelon"}, } passphrase, err := atoll.NewSecret(p) if err != nil { log.Fatal(err) } fmt.Println(passphrase) // Example output: // eremite&align&coward&casing&atoll&maximum&user&adult }
Output:
func (*Passphrase) Entropy ¶
func (p *Passphrase) Entropy() float64
Entropy returns the passphrase entropy in bits.
If the list used is "NoList" the secret must be already generated.
func (*Passphrase) Generate ¶
func (p *Passphrase) Generate() ([]byte, error)
Generate generates a random passphrase.
type Password ¶
type Password struct { // Characters that will be part of the password. Include string // Characters that won't be part of the password. Exclude string // Group of characters used to generate the pool. Levels []Level // Password length. Length uint64 // Character repetition. Repeat bool // contains filtered or unexported fields }
Password represents a sequence of characters required for access to a computer system.
Example ¶
package main import ( "fmt" "log" "github.com/GGP1/atoll" ) func main() { p := &atoll.Password{ Length: 22, Levels: []atoll.Level{atoll.Lower, atoll.Upper, atoll.Special}, Include: "1+=g ", Exclude: "&r/ty", Repeat: false, } password, err := atoll.NewSecret(p) if err != nil { log.Fatal(err) } fmt.Println(password) // Example output: // AE8f@,1^P_Ws=c!ho`T{Á+ }
Output: