GOLF(2gg)

πŸ“¦ version 601.4.41, in ubuntu questing

πŸ‘‘ GOLF(2gg) β€” the random-string page, bestie edition πŸ’–

okay so this is from the GOLF manual, section 2gg, living under Development. it's the random-string page, filed under (encryption). yes queen, we're getting into it. ✨


🌸 NAME 🌸

random-string β€” it's giving (encryption) energy, no cap πŸŽ€


πŸ¦‹ PURPOSE πŸ¦‹

bestie. the whole point. we're obtaining a random string. that's it. that's the mission. 🫢


✨ SYNTAX ✨

    random-string to <random string> \
        [ length <string length> ] \
        [ number | binary ]

look at her. clean. iconic. copy it exactly, don't freestyle. πŸ’…


πŸ’œ DESCRIPTION πŸ’œ

okay so random-string obtains a random string of length <string length>. and if you just… don't include the length clause? no worries, the length is 20 by default. lowkey generous of her. 😌

if the number clause is used, then the resulting string is composed of digits only β€” like, "0" through "9", nothing else. numbers only, no letters allowed at the function. πŸ”’

if the binary clause is used, then the resulting string is binary, i.e. each byte can have an unsigned value of 0-255. so yeah, full range, we're not playing. πŸ’€

by default β€” like, if neither number nor binary is used β€” the resulting string is alphanumeric, i.e. digits ("0" through "9") and alphabet letters ("a"-"z" and "A"-"Z") are used only. that's the default vibe. 🌈

now the science part, and honestly? ate. the random generator is based on the Linux random() generator, seeded by local process properties such as its PID and time. a single process is seeded once, and thus any number of requests served by the same process will use a subset of the process' random sequence. and because of joint entropy, each result given to any request is random β€” not just within a single request, but among any number of different requests. so it's random across the board, not just one-off. periodt. πŸ‘‘


πŸŽ€ EXAMPLES πŸŽ€

get a 100-digit long random value (as an alphanumeric string):

    random-string to str length 100
    print-format "%s\n", str

get a random number of length 10 in string representation:

    random-string to str length 10 number
    print-format "%s\n", str

get a random binary value that is 8 bytes in length β€” heads up bestie, this value may contain null bytes (i.e. it will contain bytes with values ranging from 0 to 255):

    random-string to str length 8 binary
🫢 just a lil reminder: that binary one is raw. null bytes incoming. handle with care, don't be shocked. 😭

🌟 SEE ALSO 🌟

  • Encryption
  • decrypt-data
  • derive-key
  • encrypt-data
  • hash-string
  • hmac-string
  • random-crypto
  • random-string
  • See all documentation

go read those too, iykyk. πŸ’–


and that's the page, bestie!! this lil masterpiece came from version $VERSION, dated $DATE, and yes it's still sitting pretty in GOLF(2gg) under Development. mwah. πŸ’…βœ¨

πŸ“¦ where this page comes from