Skip to content
Go package for creating random (and valid) credentials.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
postgresql
.editorconfig
LICENSE
README.md
credentials.go
credentials_test.go
go.mod
go.sum

README.md

gocredo

CircleCI

A golang package for creating random (and valid) credentials.

Right now, only PostgreSQL user accounts are supported.

And "gocredo" rhymes with "Freddo".

Examples

package main

import (
    "fmt"
    "github.com/cariad/gocredo/postgresql"
)

func main() {
    credentials, err := postgresql.MakeCredentials()

    fmt.Println(credentials.Username)
    // dodxcqhmudmhkzljkclypecsmeyjnmvqvfgenpqjlhxkrbqeaqpxtgyazxotxns

    fmt.Println(credentials.Password)
    // abrZlVkLOTzhm8By6FDZWIcKKuNZ3WahlHQqo0HiawR9osgOvi2tE5swVc9anIm
}

Value formats

PostgreSQL usernames are 63 characters long and made up of the lower-case alphabet.

PostgreSQL passwords are 63 characters long and made up of the lower-case alphabet, upper-case alphabet and decimal digits.

Functions

func MakeCredentials() (Credentials, error)

MakeCredentials returns a Credentials instance populated with randomly-generated PostgreSQL credentials.

func MakePassword() (string, error)

MakePassword returns a randomly-generated PostgreSQL user account password.

func MakeUsername() (string, error)

MakeUsername returns a randomly-generated PostgreSQL user account name.

Security

This package uses https://github.com/cariad/gorando to generate random values, and you should read that package's security notes.

Also, this package intentionally does not log any values, and converting a Credentials struct to a string will not reveal the inner values, which should protect you from accidental exposure.

   credentials, _ := postgresql.MakeCredentials()
   fmt.Println(credentials.String())
   // (credentials are secret)
You can’t perform that action at this time.