This is a GoLang library for generating cryptographically secure random numbers using the crypto/rand package. The library provides a simple API for generating random integers, bytes, and strings.
To install the library, use the go get command:
go get github.com/imusmanmalik/randomizer
To use the library, import it in your Go code:
import (
"fmt"
"github.com/imusmanmalik/randomizer"
)
func main() {
// Generate a random integer between 1 and 100
randomInt, err := randomizer.RandomInt(1, 100)
if err != nil {
panic(err)
}
fmt.Println(randomInt)
// Generate a random slice of bytes with length 16
randomBytes, err := randomizer.RandomBytes(16)
if err != nil {
panic(err)
}
fmt.Println(randomBytes)
// Generate a random string with length 32
randomString, err := randomizer.RandomString(32)
if err != nil {
panic(err)
}
fmt.Println(randomString)
}
go test
Contributions are welcome! If you find a bug or have an idea for a new feature, please open an issue or submit a pull request on GitHub.
This library is licensed under Apache 2.0 License. See the LICENSE file for details.
This library was inspired by the math/rand package in the Go standard library, and the github.com/Pallinder/go-randomdata library.