Delirium is a CLI tool and Go library that produces random values. Supports cryptographically-secure random values.
- Project structure
- How to install the CLI
- How to use the CLI
- How to install the library
- How to use the library
- Building from source
- Contributing
.
├── CODE_OF_CONDUCT.md
├── Dockerfile
├── LICENSE
├── README.md
├── SECURITY.md
├── cmd
│ └── delirium
│ └── delirium.go
├── go.mod
├── internal
│ └── constants
│ └── consts.go
└── pkg
├── pseudorand
│ └── pseudorand.go
└── securerand
└── securerand.go
I currently do not provide any prebuilt binaries for this tool. In order to install the CLI, you will need to install Go first and then run this command after Go has been installed:
go install github.com/sionpixley/delirium/cmd/delirium@latest
Make sure the GOPATH bin directory is in your PATH environment variable or the delirium
command won't be found.
The delirium
command does not require sudo/admin to use.
delirium -h
By default, the delirium
command will produce non-cryptographically-secure base64 strings with 16 bytes. If these defaults are ok with you, then run:
delirium
To change the number of bytes to use in the algorithm, specify the number of bytes with the -B
flag:
delirium -B 20
To change the algorithm to be cryptographically-secure, add the -secure
flag:
delirium -B 20 -secure
To change the encoding to use base64's URL-safe encoding, specify the -encoding
flag with the value base64url
:
delirium -encoding=base64url
Regardless of the encoding used, you can still specify the number of bytes to use and whether to make the algorithm cryptographically-secure:
delirium -encoding=base64url -B 20 -secure
To change the encoding to use hexadecimal, specify the -encoding
flag with the value hex
:
delirium -encoding=hex
Regardless of the encoding used, you can still specify the number of bytes to use and whether to make the algorithm cryptographically-secure:
delirium -encoding=hex -B 20 -secure
delirium -v
go get github.com/sionpixley/delirium
Delirium is a Go module that comes with two packages: securerand
and pseudorand
. The securerand
package is a wrapper around the Go standard library crypto/rand and produces cryptographically-secure random values. The pseudorand
package is a wrapper around the Go standard library math/rand/v2 and produces random values that are not cryptographically-secure.
Make sure to include the import:
import "github.com/sionpixley/delirium/pkg/securerand"
secureRandomBytes, err := securerand.Bytes(<insert-num-of-bytes>)
secureRandomBase64, err := securerand.Base64String(<insert-num-of-bytes>, false)
secureRandomBase64, err := securerand.Base64String(<insert-num-of-bytes>, true)
secureRandomHex, err := securerand.HexString(<insert-num-of-bytes>)
Make sure to include the import:
import "github.com/sionpixley/delirium/pkg/pseudorand"
randomBytes := pseudorand.Bytes(<insert-num-of-bytes>)
randomBase64 := pseudorand.Base64String(<insert-num-of-bytes>, false)
randomBase64 := pseudorand.Base64String(<insert-num-of-bytes>, true)
randomHex := pseudorand.HexString(<insert-num-of-bytes>)
There are two main ways to build Delirium from source: Building with Go directly or building the Dockerfile.
Building with the Dockerfile is good for quick local testing.
- Go 1.23.6
go build -o delirium ./cmd/delirium
go build -o delirium.exe ./cmd/delirium
- Docker
docker build -t delirium .
All contributions are welcome! If you wish to contribute to the project, the best way would be forking this repo and making a pull request from your fork with all of your suggested changes.