Skip to content

Latest commit

 

History

History
65 lines (46 loc) · 2.38 KB

README.md

File metadata and controls

65 lines (46 loc) · 2.38 KB

randomizer

Coverage Status CI Build CI Test CI Scan CI Release Go Reference

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.

Installation

To install the library, use the go get command:

go get github.com/imusmanmalik/randomizer

Usage

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)
}

Testing

go test

Contributing

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.

License

This library is licensed under Apache 2.0 License. See the LICENSE file for details.

Acknowledgments

This library was inspired by the math/rand package in the Go standard library, and the github.com/Pallinder/go-randomdata library.