randomstring

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: BSD-3-Clause Imports: 3 Imported by: 16

README

randomstring

Generate random strings.

These are the exported function signatures:

func PickLetter() rune
func PickVowel() rune
func PickCons() rune
func Seed()
func String(length int) string
func EnglishFrequencyString(length int) string
func HumanFriendlyString(length int) string
func CookieFriendlyString(length int) string
func CookieFriendlyBytes(length int) []byte
func HumanFriendlyEnglishString(length int) string

Used by cookie and alienpdf.

General info
  • Version: 1.2.0
  • License: BSD-3

Documentation

Overview

Package randomstring can be used for generating different types of random strings

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CookieFriendlyBytes added in v1.1.0

func CookieFriendlyBytes(length int) []byte

CookieFriendlyBytes generates a random, but cookie-friendly, byte slice of the given length.

func CookieFriendlyString

func CookieFriendlyString(length int) string

CookieFriendlyString generates a random, but cookie-friendly, string of the given length.

func CookieFriendlyStringNoAlloc added in v1.2.0

func CookieFriendlyStringNoAlloc(placeholder []byte)

CookieFriendlyStringNoAlloc generates a random, but cookie-friendly, string. The bytes of the string are stored in the given byte slice.

func EnglishFrequencyString

func EnglishFrequencyString(length int) string

EnglishFrequencyString returns a random string that uses the letter frequency of English, ref: http://pi.math.cornell.edu/~mec/2003-2004/cryptography/subs/frequencies.html

func HumanFriendlyEnglishString

func HumanFriendlyEnglishString(length int) string

HumanFriendlyEnglishString generates a random, but human-friendly, string of * the given length. It should be possible to read out loud and send in an email * without problems. The string alternates between vowels and consontants. * * The vowels and consontants are wighted by the frequency table

func HumanFriendlyString

func HumanFriendlyString(length int) string

HumanFriendlyString generates a random, but human-friendly, string of

  • the given length. It should be possible to read out loud and send in an email
  • without problems. The string alternates between vowels and consontants. *
  • Google Translate believes the output is Samoan. *
  • Example output for length 7: rabunor

func PickCons

func PickCons() rune

PickCons will pick a consonant, weighted by the frequency table

func PickLetter

func PickLetter() rune

PickLetter will pick a letter, weighted by the frequency table

func PickVowel

func PickVowel() rune

PickVowel will pick a vowel, weighted by the frequency table

func Seed

func Seed()

Seed the random number generator in one of many possible ways.

func String

func String(length int) string

String generates a random string of a given length.

func StringNoAlloc added in v1.2.0

func StringNoAlloc(placeholder []byte)

StringNoAlloc generates a random string in the given byte slice, but does not allocate memory with "make".

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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