Skip to content

v1.0.0: Full rewrite, better API and new features

Compare
Choose a tag to compare
@wneessen wneessen released this 14 Mar 10:29
· 450 commits to main since this release
ddae28d

Welcome to apg-go v1

This is a full rewrite of apg-go! We've changed the complete API to make it more accessible to developers that want to make sure of apg-go's functionality in their own codebase. Not only that but also is the code base much cleaner and has almost full test coverage now. We've also changed the way on how we release. Instead of using Github actions we now make use of the incredible GoReleaser, allowing us to have pre-built packages for lots of OS/architectures as well as pre-compiled packages for lots of Linux distributions. Everything is also now GPG signed for improved security.

New features

New API

Since v1 is full rewrite, the API has changed completely. Everything is now bound to a Generator, while the password requirements are bound to a Config. The Generator will use the Config for all the password generation tasks.

Here is a simple code example that shows how easy and accessible the API now is:

package main

import (
        "fmt"

        "github.com/wneessen/apg-go"
)

func main() {
        config := apg.NewConfig(
                apg.WithAlgorithm(apg.AlgoRandom),
                apg.WithModeMask(apg.ModeSpecial|apg.ModeNumeric|apg.ModeLowerCase|apg.ModeUpperCase),
                apg.WithFixedLength(15))
        generator := apg.New(config)
        password, err := generator.Generate()
        if err != nil {
                panic(err)
        }
        fmt.Println("Your password:", password)
}

For full details, check the Godoc reference.

Coinflip mode

Sometimes you just want to quickly perform a simple, but random coinflip. Since v1.0.0 apg-go has a coinflip mode, which will return either "Heads" or "Tails". To use coinflip mode, use the -a 2 argument:

$ ./apg -n 10 -a 2
Tails
Tails
Heads
Heads
Tails
Tails
Tails
Tails
Heads
Heads

Minimum required characters

Even though in apg-go you can select what kind of characters are used for the password generation, it is
not guaranteed, that if you request a password with a numeric value, that the generated password will
actually have a numeric value. Since v1.0.0 apg-go has a new set of arguments, that let's you define
a minimum amount of characters of a specific character class to be included in the generated password.
This can be requested with the -mL, -mN, -mS and -mU arguments. Each stands for the corresponding
character class. If one of the arguments is give, apg-go will generate passwords until the requested amount
of characters of the corresponding class is given.

Note on minimum characters: Please keep in mind, that due to the way the "minimum amount" feature works,
the calculation time for passwords can increase and if the amount is set too high, it can result in apt-go
never being able to finish the job.

Example:

$ ./apg -n 10 -a 1 -M NLUs -f 20 -mN 3
kqFG935E280LvTFUbJ4M
RVBJAI5tJ6hy6oWrNfXG
uy1IWBEoOQFyG66VrLqu
T5k9oKieImvJ9hxePfHt
0TTpGzMUje6mU7IXaSII
gvDjPmlj8J6glR0iy0h4
C5OP3Ph7bx173v0gRNsn
SEuP7I3en6ai9OuHvNSs
yira1uPQ8qmo5OKUM4Er
bu0nzhjoKn8Uiy3H2RjD

Better test coverage

We now have actul unit tests in the apg-go code base. Currently the coverage is ~85% and we are working to improve it even more- where possible.

Changelog

Full Changelog: v0.4.1...v1.0.0