GitXplorerGitXplorer
t

go-securerandom

public
2 stars
1 forks
0 issues

Commits

List of commits on branch master.
Unverified
2a874cd5ff28241884bdd86c46f46b8b7485264b

bump version to v0.1.1

ttheckman committed 9 years ago
Unverified
14e10d811027778a71849e3286d6f5b15de8edfd

Merge pull request #7 from theckman/use_math/rand_true_namespace

ttheckman committed 9 years ago
Unverified
62859c488ee5423af782d8da3359a16dfb0cc344

remove alias from math/rand import

ttheckman committed 9 years ago
Unverified
0f592974da9c7208a421ea3f9e71fe0f2f323130

add license information to the README file

ttheckman committed 9 years ago
Unverified
5d5760623d243a74e107ce4dcd26ad916a109d2c

Merge pull request #6 from theckman/more_funcs

ttheckman committed 9 years ago
Unverified
babaf3a7a608ddeeb93d44a93d0252cd4e557c48

generation of a string from N bytes of securerandom data; v0.1.0

ttheckman committed 9 years ago

README

The README file for this repository.

go-securerandom

TravisCI Build Status :: theckman/go-securerandom GoDoc :: github.com/theckman/go-securerandom License

Package securerandom is a set of utilities for generating random data from the crypto/rand package. The package has the ability to generate bytes from secure-random data, as well as other data from those bytes. That includes numbers and Base64-encoded strings.

License

go-securerandom is released under the BSD 3-Clause License. See the LICENSE file for the full contents of the license.

Installation

go get -u github.com/theckman/go-securerandom

Usage

Full usage information can be found on the GoDoc page, but here is a short example:

import (
	"fmt"
	"math/rand"
	"github.com/theckman/go-securerandom"
)

ri64, err := securerandom.GenerateRandomInt64()

// secure-random data is unavailable
if err != nil {
	// handle err
}

rand.Seed(ri64)

You can also generate random base64 encoded strings from this package:

// generate string from 32 random bytes
rStr, err := securerandom.Base64OfBytes(32)

// secure-random data is unavailable
if err != nil { /* handle err */ }

fmt.Println(rStr)

// assume your random string can only be 32 bytes long
rStr, _ = securerandom.Base64InBytes(32)

fmt.Println(rStr) // would print Base64 string with a length of 32