Skip to content

Latest commit

 

History

History
112 lines (84 loc) · 2.88 KB

pwgen_functions.md

File metadata and controls

112 lines (84 loc) · 2.88 KB

Template Functions

word

Outputs a random word from the wordlist. For title case, the output can be piped to title.

Examples

  • Lowercase:
    {{ word }}
    
  • Title case:
    {{ title word }}
    

words

Outputs a slice of random words from the wordlist. The output will be a slice, which can be joined using join. For title case, the output can be piped to title.

Examples

  • Lowercase, joined with -:
    {{ words 3 | join "-" }}
    
  • Title case, joined with -:
    {{ words 3 | join "-" | title }}
    

wordsWithNum, wordsWithNumber

Behaves similarly to words, but will append a random number to one of the words.

Examples

{{ wordsWithNumber 3 | join "-" }}

num, number, numeric

Alias for Sprig's randNumeric function. A random number will be generated with the number of digits determined by the parameter.

Examples

  • Generate a number from 0-9:
    {{ num 1 }}
    
  • Generate a number from 10-99:
    {{ num 2 }}
    

alpha

Alias for Sprig's randAlpha function. Random letters will be generated with the length determined by the parameter.

Examples

  • Generate a random string of letters:
    {{ alpha 32 }}
    

alphaNum

Alias for Sprig's randAlphaNum function. Random letters and numbers will be generated with the length determined by the parameter.

Examples

  • Generate a random string of letters and numbers:
    {{ alphaNum 32 }}
    

ascii

Alias for Sprig's randAscii function. Random letters, numbers, and symbols will be generated with the length determined by the parameter.

Examples

  • Generate a random string of letters, numbers, and symbols:
    {{ ascii 32 }}
    

binary

Random binary data will be generated with number of bytes determined by the parameter. Useful with b64enc.

Examples

  • Generate a random base64 string with 32 bytes of data:
    {{ binary 32 | b64enc }}
    

shuffle

Randomly shuffles a slice/list.

Examples

  • Shuffles a list of numbers:
    {{ list 1 2 3 4 5 6 | shuffle | join "" }}