randomstrings

package module
v0.0.0-...-88fd7c5 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2016 License: MIT Imports: 2 Imported by: 11

README

Random Strings in GoLang

This simple library creates random strings on N length

Thanks to @elithrar for the code! Source: https://elithrar.github.io/article/generating-secure-random-numbers-crypto-rand/

Usage

import "github.com/adam-hanna/randomstrings"

sRand, err := randomstrings.GenerateRandomString(16) // generates a 16 digit random string
if err != nil {
	// panic!
}
log.Println(sRand)

Documentation

Overview

thanks to @elithrar for the code to create the secret token! source: https://elithrar.github.io/article/generating-secure-random-numbers-crypto-rand/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateRandomBytes

func GenerateRandomBytes(n int) ([]byte, error)

GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GenerateRandomString

func GenerateRandomString(s int) (string, error)

GenerateRandomString returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

Types

This section is empty.

Jump to

Keyboard shortcuts

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