GOLF(2gg)
π GOLF(2gg) β okay bestie, let's talk about this gorgeous little page
So this is a page from the 2gg manual, and it's all about the derive-key thing. Encryption energy. Very main character. Let's get into it. π
β¨ NAME β¨
derive-key β (encryption) π¦
π― PURPOSE π―
Derive a key. That's it. That's the whole vibe. π
πΈ SYNTAX πΈ
derive-key <key> from <source> length <length> \
[ binary [ <binary> ] ] \
[ from-length <source length> ] \
[ digest <digest algorithm> ] \
[ salt <salt> [ salt-length <salt length> ] ] \
[ iterations <iterations> ]
Copy it exactly, don't freestyle, she's specific. π
π DESCRIPTION π
Okay so derive-key derives <key> from the string <source> β that's the one sitting in the from clause. If you specify <source length> in the from-length clause, then exactly <source length> bytes of <source> get used. No from-length clause? Then the length of the <source> string itself is used as the number of bytes (peep string-length for that one). β¨
The length you want for your derived key goes in the length clause as <length>. The method doing the generating is PBKDF2, no cap. By default the digest is SHA256. Wanna switch it up? Drop a different <digest algorithm> into the digest clause (like SHA3-256, she's cute). And if you wanna see the whole list of available digests:
#get digests
openssl list -digest-algorithms
Salt for the key derivation? That's <salt> in the salt clause. If you don't add a salt-length clause, then the entire length of the salt gets used (again, string-length β she's everywhere), otherwise <salt length> bytes get used as the salt. π§
Iterations go in the iterations clause as <iterations>. The default is 1000 per RFC 8018 β though honestly, depending on what you need and how good your <source> is, you might wanna pick a different number. Do you, bestie. π
By default the derived key comes out in hexadecimal form, where every byte is encoded as two-character hex characters, so its length is 2*<length>. But if you use the binary clause without the boolean variable <binary>, or if <binary> evaluates to true, then the output is a binary string of <length> bytes. π¦
Key derivation is often used when you're storing password-derivatives in the database (with salt, obviously), and also for symmetrical key generation. Iconic behavior honestly. π
π₯ EXAMPLES π₯
Here's the derived key landing in the variable mk:
random-string to rs9 length 16
derive-key mk from "clave secreta" digest "sha-256" salt rs9 salt-length 10 iterations 2000 length 16
Ate. π
π SEE ALSO π
- Encryption
Also go check out these:
decrypt-dataderive-keyencrypt-datahash-stringhmac-stringrandom-cryptorandom-string
And See all documentation if you're feeling adventurous. π
Not me writing a whole sign-off section but fr fr, this page is version$VERSION, dated$DATE, and it lives in the GOLF(2gg) manual. Slay, bye bestie! πβ¨ππ«Ά
π¦ where this page comes from
- ubuntu questing: golf 601.4.41-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms