randomizer

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2023 License: Apache-2.0 Imports: 2 Imported by: 1

README

randomizer

Coverage Status CI Build CI Test CI Scan CI Release

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 0 and 100
    n := yourpackage.RandomInt(100)
    fmt.Println(n)

    // Generate a random byte slice with 16 bytes
    b := yourpackage.RandomBytes(16)
    fmt.Printf("%x\n", b)

    // Generate a random string with 10 characters
    s := yourpackage.RandomString(10)
    fmt.Println(s)
}

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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

type Generator struct {
}

Generator is a struct that holds the random generator's configuration.

func NewGenerator

func NewGenerator() *Generator

NewGenerator returns a new instance of the random generator.

func (*Generator) Float64

func (g *Generator) Float64() (float64, error)

Float64 returns a cryptographically secure random float64 between 0 and 1.

func (*Generator) Intn

func (g *Generator) Intn(n int) (int, error)

Intn returns a cryptographically secure random integer between 0 and n.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL