randstr is a module that contains functions for generating random strings.

randstr

randstr is a module that contains functions for generating random strings.

The functions in this module uses the crypto/rand package.

Installation

go get github.com/henrikac/randstr

Usage

The strings generated by Generate and GenerateLen are all unbiased, meaning that each of the characters in the character set a-zA-Z0-9 (62 characters) has an equal chance of being used in the generated string.

Generate

randstr.Generate returns a random string that is 16 characters long.

package main

import (
	"fmt"
	"log"

	"github.com/henrikac/randstr"
)

func main() {
	str, err := randstr.Generate()
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%s\n", str)
}

// Example output:
// 4a1Lz3d4yXihvbJX

GenerateLen

randstr.GenerateLen returns a random string of the specified length.

package main

import (
	"fmt"
	"log"

	"github.com/henrikac/randstr"
)

func main() {
	str, err := randstr.GenerateLen(20)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%s\n", str)
}

// Example output:
// bRXVtwgaLVsBuYJtP9Lf

Base64Encoded

randstr.Base64Encoded returns a random base64 encoded string.

package main

import (
	"fmt"
	"log"

	"github.com/henrikac/randstr"
)

func main() {
	str, err := randstr.Base64Encoded()
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%s\n", str)
}

// Example output:
// M72WQsavclA/wLYfxuyr2Q==

Contributing

  1. Fork it (https://github.com/henrikac/randstr/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

Owner
Similar Resources

Daypaper sets your GNOME wallpaper based on the time of day from a random and relevant Unsplash image.

Daypaper Daypaper sets your GNOME wallpaper based on the time of day from a random and relevant Unsplash image. Installation You will need an Access T

May 23, 2022

✔️ Get random data for your app from a third-party source.

Random Data Securely produced random data for application testing. FAQ What would i use this data for? You can use this information to test your apps

Jul 5, 2022

Encriptator using random generated numbers

public-private-key-encrypter Encriptator using random generated numbers The input file must be in one file called 'data.txt' The execution will genera

Oct 15, 2021

Just some random matchers

Just some random matchers

The package provides a matcher interface to match a given value of any types.

Nov 3, 2022

generate random data like name, email, uuid, address, images and etc.

gg-rand generate random data like name, email, uuid, address, images and etc. build and install: make run: gg-rand $ gg-rand SillyName : Knavesa

Nov 16, 2022

Generate some random data

fake-data-generator-api generate some random data installing and using

Dec 2, 2022

Generates a random alphanumeric string of a given length.

randstring randstring.Create () is fast and has minimal memory allocation. It returns a random alphanumeric string of a given length. Install go get g

Jan 7, 2022

GoApiRandom - Api to get random numbers

GoApiRandom - Api to get random numbers

Jan 18, 2022

Generates random text based on trigrams generated from input text

Generates random text based on trigrams generated from input text

Trigrams Generates random text based on trigrams generated from input text Contents Building Running Using Implementation notes NGram size Maximum wor

Feb 9, 2022
Related tags
Simple library to handle ANSI functions and parsing of color formatting strings

Emerald A basic color library for use in my Go projects, built on top of mgutz/ansi. Package ansi is a small, fast library to create ANSI colored stri

Oct 28, 2022
A library for parsing ANSI encoded strings
 A library for parsing ANSI encoded strings

Go ANSI Parser converts strings with ANSI escape codes into a slice of structs that represent styled text

Sep 20, 2022
Simple go package which converts roman strings to integer

romanparse Simple go package which converts roman strings

Aug 11, 2022
GoWrap is a command line tool for generating decorators for Go interfaces

GoWrap GoWrap is a command line tool that generates decorators for Go interface types using simple templates. With GoWrap you can easily add metrics,

Dec 30, 2022
bebop is a bebop parser written in Go, for generating Go code.

bebop is a bebop parser written in Go, for generating Go code. bebop can read .bop files and output .go files representing them: package main i

Dec 24, 2022
Template repo for generating your own workflow executor for Azure Orkestra

Orkestra Workflow Executor Template Repo This is a template repository for a new workflow executor Usage Generate your repository from this template b

Oct 22, 2021
Generating sitemap using goLang

This Go Module will generate the sitemap for any given URL. We will travese the all pages of the website and creates the sitemap We will use the 'net/

Dec 9, 2021
This project contains an example that showcases different features from the official Go Client for Elasticsearch
This project contains an example that showcases different features from the official Go Client for Elasticsearch

Elasticsearch for Gophers This project contains an example that showcases different features from the official Go Client for Elasticsearch that you ca

Oct 12, 2022
A lib of golang which contains many funny api;

A lib of golang which contains many funny api; I created it cause I could not find these more-effient apis from other repo.

Oct 27, 2021
Fast, scalable pseudo random number generator based on xxh3
Fast, scalable pseudo random number generator based on xxh3

XXH3-Based Pseudorandom Number Generator This package contains an experimental implementation of a noise based pseudorandom number generator that scal

Nov 24, 2022