GOLF(2gg)

πŸ“¦ version 601.4.41, in ubuntu questing

πŸ’… GOLF(2gg) β€” the manual, but make it cute

okay bestie, so this is from the Development part of the manual (it's a 2gg page, iykyk), and it's literally just about hashing strings. iconic behaviour honestly. let's get into it 🫢


✨ NAME ✨

hash-string β€” (encryption)


🎯 PURPOSE 🎯

Hash a string. that's it. that's the whole job. she's a one-trick pony and she ATE πŸ’…


πŸ“œ SYNTAX πŸ“œ

hash-string <string> to <result> \
    [ binary [ <binary> ] \
    [ digest <digest algorithm> ]

look at her. so structured. so slay ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so hash-string takes your <string> and by default gives you back a SHA256 hash of it β€” but only if you don't use the "digest" clause, bestie. the result gets stored into <result>. no cap.

want something different? you can swap in a different <digest algorithm> using the "digest" clause (like, say, "SHA3-256" for example πŸ’–). and if you wanna see the whole menu of available digests:

#get digests
openssl list -digest-algorithms

okay now here's the tea on "binary" πŸ“. If the "binary" clause is used without a boolean variable <binary>, or if <binary> evaluates to true, then your <result> is a binary string β€” which means it may contain null-characters. wild, i know. and the lengths? with the default SHA256 it's 32 bytes long, while with something like SHA3-384 it's 48 bytes long, etc. the math is mathing πŸ“

if you don't use the "binary" clause, or if <binary> evaluates to false, then each binary byte of the hashed string gets converted into two hexadecimal characters ("0"-"9" and "a"-"f"), which means <result> is twice as long as it would be with the "binary" clause. double the length, double the drama πŸ’€


🌸 EXAMPLES 🌸

so the string "result" will have a hashed value of whatever string you gave it, and an example of that might look something like:

e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

here's how you'd actually run it:

hash-string "hello world" to hash

using a different digest? say less:

hash-string "hello world" to hash digest "sha3-384"

producing a binary value instead of a null-terminated hexadecimal string:

hash-string "hello world" to hash digest "sha3-384" binary

three examples, all gorgeous, all serving πŸ’œ


πŸ‘€ SEE ALSO πŸ‘€

Encryption

decrypt-data derive-key encrypt-data hash-string hmac-string random-crypto random-string

See all documentation πŸ“š


and that's the whole page bestie!! no notes, she's perfect. this one was served up from the Development section, dated $DATE, version $VERSION, and yes it's still GOLF(2gg) at the end of the day. go hash something and slay πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from