A safe time-independent random number/string generator.

RanGo Logo

🦎 RanGo PkgGoDev Go Report Card Go version Go coverage GitHub license

A time-independent random number/string generator.

πŸ“¦ Installation

First:

go get github.com/yektadev/rango

Then, add the dependency to your code:

import "github.com/yektadev/rango"

πŸ“ Simple Usage

Here's all you need to do in order to:

πŸ”Ί Generate a random int:

Use:

RanGo.RnInt(startIncluded int, endNotIncluded int)

Example:

r := RanGo.RnInt(0,8)  //r Ο΅ {0,1,2,...,6,7}

πŸ”Ί Generate a random string from a set of characters:

Use:

RanGo.RnStringFrom(length int, chars string)

Example:

r := RanGo.RnStringFrom(8,"abcd")  //r (example): "dadaadbb"

πŸ”Ί Generate a random string:

Use:

RanGo.RnString(length int, containsLowercase bool, containsUppercase bool, containsNumber bool, containsSpecial bool)

Examples:

r := RanGo.RnString(18,true,true,true,true)  //r (example): "}WCg*(?w4P$<HS\jOb"
r := RanGo.RnString(18,true,false,false,false)  //r (example): "jzoqagpchhsyhotvrj"
r := RanGo.RnString(18,false,false,true,false)  //r (example): "325803510203358683"

πŸ”§ More Options

If the above functions face an error while generating a time-independent seed, the seed will be automatically generated using time.Now().UnixNano(). If you need to know whether the seed is generated time-dependent or time-independent, then use the following functions:

  • RandomInt() instead of RnInt().
  • RandomStringFrom() instead of RnStringFrom().
  • RandomString() instead of RnString().

In case of using these functions, you'll have isSeedTimeDependent boolean as the second returned output.


Special thanks to John Leidegren because of this answer on Stack Overflow.

Owner
Ali Khaleqi Yekta
Just another developer; a passionate one!
Ali Khaleqi Yekta
Similar Resources

k6 query generator for graphite API

xk6-carbonapi This is a k6 extension using the xk6 system. ❗ This is a proof of concept, isn't supported by the k6 team, and may break in the future.

Dec 1, 2022

A kubernetes operator demo generated by code-generator, it only watches cr's events

intro a small operator demo which only watches car cr's events. environment: ubuntu-20.04-amd64 k3s-1.21 docker-20.10.7 go-1.17 tools code-generator d

Dec 13, 2021

Password generator for golang

Password generator by Distemi(D####Fox) Russian(Русский) How to run this program

Dec 19, 2021

Code generator to help implement the visitor pattern.

mkvisitor Given package example type ( Node struct{} Leaf struct{} ) run mkvisitor -type "Node,Leaf" then generate package example import "fmt" t

Oct 6, 2021

ubume - Golang project generator

ubume - Golang project generator ubume command generate golang project at current directory. Currently, ubume can only generate application projects.

Dec 17, 2022

Mango-kong - Mango (man page generator) integration for Kong

Mango-kong - Mango (man page generator) integration for Kong

Mango (man page generator) integration for Kong This package allows Kong package

Dec 5, 2022

A Teardown API to Lua stub generator written in Go.

Teardown API Stub Generator This project aims to provide a parser for the XML files at https://www.teardowngame.com/modding/api.xml These files descri

Oct 28, 2022

Time Series Alerting Framework

Bosun Bosun is a time series alerting framework developed by Stack Exchange. Scollector is a metric collection agent. Learn more at bosun.org. Buildin

Dec 27, 2022

Monitor your Website and APIs from your Computer. Get Notified through Slack, E-mail when your server is down or response time is more than expected.

Monitor your Website and APIs from your Computer. Get Notified through Slack, E-mail when your server is down or response time is more than expected.

StatusOK Monitor your Website and APIs from your computer.Get notified through Slack or E-mail when your server is down or response time is more than

Dec 27, 2022
Comments
  • Help

    Help

    hello sir Sorry to bother I was going through GitHub to see if I could find help then I stumbled on your repo, The problem I have is with this Go code

    package main

    // Project rand-string // file: main.go // Author: handsomekaizer [email protected] // Description: random string generator

    import ( "crypto/rand" "fmt" "math/big" )

    const RANDOM_STR_LEN = 10

    func shuffleDict(dict string) []rune { shuffledDict := []rune(dict) for i := 0; i < len(dict); i++ { r, _ := rand.Int(rand.Reader, big.NewInt(int64(len(dict)))) randn := r.Int64() char := shuffledDict[i] shuffledDict[i] = shuffledDict[randn] shuffledDict[randn] = char } return shuffledDict }

    func main() { fmt.Println("Here:") var dictionary string = "abcdefghiklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" for k := 0; k < 100; k++ { shuffledDict := shuffleDict(dictionary) for j := 0; j < RANDOM_STR_LEN; j++ { i, _ := rand.Int(rand.Reader, big.NewInt(int64(len(dictionary)))) fmt.Printf("%c", shuffledDict[i.Int64()]) } fmt.Printf("\n") } }

    The Go code is ok, it generates 10 alphanumeric characters. but I wanted you to help me add a function where it generates the 10 alphanumeric characters and replaces ********** in this characters below

    5m**********kbgTRZhiS5sjGMpmcRZdPAhmWLRfpmutGmPHtjklob

    with the 10 alphanumeric characters it generates.

    thanks

I'd like to share random apps in the spare times. Thus, I'm going to try learning some concepts of Go and as much as I can I try to clarify each line.

go-samples I'd like to share random apps in the spare times. Thus, I'm going to try learning some concepts of Go and as much as I can I try to clarify

Mar 16, 2022
An app that fetches a random name and joke, and combines them.
An app that fetches a random name and joke, and combines them.

Wildfire Backend Assessment An app that fetches a random name and joke, and combines them.

Jan 29, 2022
sget is a keyless safe script retrieval and execution tool

sget ⚠️ Not ready for use yet! sget is a keyless safe script retrieval and execution tool Security Should you discover any security issues, please ref

Dec 18, 2022
Image clone controller is a kubernetes controller to safe guard against the risk of container images disappearing

Image clone controller image clone controller is a kubernetes controller to safe guard against the risk of container images disappearing from public r

Oct 10, 2021
Chai - type safe http handlers with automatic swagger generation
Chai - type safe http handlers with automatic swagger generation

chai Description chai is an extension for a few popular http routers that adds s

Feb 25, 2022
Generic sharded thread safe LRU cache in Go.

cache Cache is a thread safe, generic, and sharded in memory LRU cache object. This is achieved by partitioning values across many smaller LRU (least

Sep 12, 2022
HTTP load generator, ApacheBench (ab) replacement, formerly known as rakyll/boom
HTTP load generator, ApacheBench (ab) replacement, formerly known as rakyll/boom

hey is a tiny program that sends some load to a web application. hey was originally called boom and was influenced from Tarek Ziade's tool at tarekzia

Jan 3, 2023
πŸ¦₯ Easy and simple Prometheus SLO generator
πŸ¦₯ Easy and simple Prometheus SLO generator

Sloth Introduction Use the easiest way to generate SLOs for Prometheus. Sloth generates understandable, uniform and reliable Prometheus SLOs for any k

Jan 4, 2023
Semantic version generator using git commit keywords and overrides

Semantic version generator Project created overnight, to prove that management of semantic versioning is NOT painful and do not require arguments and

Jan 1, 2023
a fast changelog generator sourced from PRs and Issues

chronicle A fast changelog generator that sources changes from GitHub PRs and issues, organized by labels. chronicle --since-tag v0.16.0 chronicle --s

Nov 19, 2022