6. Even single-line code needs
7. Code blocks MUST contain EXACT original code — NO changes
8. No emoji inside
9. Use - or
- for lists
10. Don't replace list structure with emoji-only lines
11. Function references:
name(args) — description
12. XSS prevention: escape < and > not part of allowed tags
13. Output only valid HTML
14. Preserve original information
15. Preserve , , tags
16. Add emoji to options and lists
17. Keep original structure
18. 🚀 Quick Reference section after NAME
19. Exit Codes section only if original lists exit codes (none here)
20. Under 128,000 chars
Let me carefully process this:
The original has these sections:
- NAME → h2 with emoji
- LIBRARY → h2 with emoji
- SYNOPSIS → h2 with emoji
- DESCRIPTION → h2 with emoji
- RETURN VALUES → h2 with emoji
- ERRORS → h2 with emoji
- FEATURE TEST MACROS → h2 with emoji (has sub-content)
- PORTABILITY NOTES → h2 with emoji
- ATTRIBUTES → h2 with emoji (table)
- SEE ALSO → h2 with emoji
Let me add the 🚀 Quick Reference section after NAME.
Now let me carefully write the code blocks. The SYNOPSIS has C code with #include and function prototypes. I need to escape < and > which become < and >.
Let me write this out:
For synopsis:
```
#include <crypt.h>
char *
crypt_gensalt(const char *prefix, unsigned long count,
const char *rbytes, int nrbytes);
char *
crypt_gensalt_rn(const char * prefix, unsigned long count,
const char *rbytes, int nrbytes, char * output, int output_size);
char *
crypt_gensalt_ra(const char *prefix, unsigned long count,
const char *rbytes, int nrbytes);
```
Wait — the original has `const char * prefix` (with space) and `char * output` in the second function. Let me preserve EXACTLY.
Let me also note: the original has the attribute table in raw text form with +---+ borders. I should preserve this in a or convert it to a proper HTML table. Since the rules say to preserve original structure, and this is essentially a table, I'll use a block to keep it as-is.
Actually wait, looking at the structure, the +---+ lines indicate it's a table. I could keep it as a pre block (since converting to would be restructuring). But it would be cleaner to convert. Let me convert to since this is a true table - that improves readability without losing information.
Hmm, actually rule 14 says preserve original HTML structure. Let me keep it as a pre block. Or actually since the input isn't tags but raw text, I can convert it to HTML. Let me think... the input is in text form with dashes. Converting to HTML table improves scannability. I'll do that.
For the attributes, the interfaces column spans two rows in the original. Let me handle that.
Let me also consider:
- The `crypt_gensalt_rn, crypt_gensalt_ra` entry spans one row visually in source
Let me write the final output. Quick reference table — I need to generate common use cases. Let me think about what would be useful:
| Use Case | Command | Description |
|---------|---------|-------------|
| Generate salt with default settings | `crypt_gensalt(NULL, 0, NULL, 0)` | Select best method, default cost, OS entropy |
| Generate salt for SHA-512 | `crypt_gensalt("$6$", count, NULL, 0)` | SHA-512 hashing with custom cost |
| Generate salt for bcrypt | `crypt_gensalt("$2b$", count, NULL, 0)` | bcrypt hashing |
| Reentrant version | `crypt_gensalt_rn(prefix, count, rbytes, n, buf, sz)` | Thread-safe, caller-provided buffer |
| Allocate result | `crypt_gensalt_ra(prefix, count, NULL, 0)` | Returns malloc'd buffer (free with free) |
Let me finalize. Now carefully checking for XSS - I need to escape all bare < and > characters. Let me scan:
- In synopsis: `#include ` needs `<crypt.h>`
- Function prototypes use `*` (pointer) which is fine
- In FEATURE TEST MACROS description: `` needs escaping
- In PORTABILITY NOTES: nothing problematic
- Everywhere else?
Let me do the full thing now.
Let me also use for sub-sections within the FEATURE TEST MACROS section since the macros are listed there with a tab/indent in original.
Looking at original FEATURE TEST MACROS:
- CRYPT_GENSALT_IMPLEMENTS_DEFAULT_PREFIX
- CRYPT_GENSALT_IMPLEMENTS_AUTO_ENTROPY
These are described with indented text after them. I'll use a or just
with for the names and text description.
Actually, let me use a regular paragraph with the code and description preserved.
Let me also handle the ATTRIBUTES table - I'll preserve it as the original text table (in pre/code) since that's how it appears, OR convert to HTML table. Let me convert to HTML table for better presentation, since the input is structural data even if formatted in man page style.
Actually, I'll be safe and preserve the original tabular text format with . Wait, but the rules say section content shouldn't be in pre/code unless it's actual code. This is a man page table, not code. Converting to HTML table is appropriate.
OK, let me convert to HTML table. The original table has:
- crypt_gensalt | Thread safety | MT-Unsafe race:crypt_gensalt
- crypt_gensalt_rn, crypt_gensalt_ra | Thread safety | MT-Safe
For Quick Reference I need a table. Let me write it out.
Now putting it all together. Let me be careful with character counts - keep under 128k.
🔐 NAME
crypt_gensalt, crypt_gensalt_rn, crypt_gensalt_ra — encode settings for passphrase hashing
🚀 Quick Reference
Use Case Command Description
Best available hash crypt_gensalt(NULL, 0, NULL, 0)Auto-selects method, default cost, OS entropy
SHA-512 hashing crypt_gensalt("$6$", count, NULL, 0)Generate salt using SHA-512 with custom cost
bcrypt hashing crypt_gensalt("$2b$", count, NULL, 0)Generate salt using bcrypt
Thread-safe buffer crypt_gensalt_rn(prefix, count, rbytes, n, buf, sz)Caller-supplied output buffer (reentrant)
Heap allocation crypt_gensalt_ra(prefix, count, rbytes, n)Allocates result with malloc — free with free()
Check feature support CRYPT_GENSALT_IMPLEMENTS_DEFAULT_PREFIXTest if NULL prefix is supported
📚 LIBRARY
Crypt Library (libcrypt, -lcrypt)
📝 SYNOPSIS
#include <crypt.h>
char *
crypt_gensalt(const char *prefix, unsigned long count,
const char *rbytes, int nrbytes);
char *
crypt_gensalt_rn(const char * prefix, unsigned long count,
const char *rbytes, int nrbytes, char * output, int output_size);
char *
crypt_gensalt_ra(const char *prefix, unsigned long count,
const char *rbytes, int nrbytes);
📖 DESCRIPTION
The crypt_gensalt, crypt_gensalt_rn, and crypt_gensalt_ra functions compile a string for use as the setting argument to crypt, crypt_r, crypt_rn, and crypt_ra. 🧩
- 🏷️ prefix selects the hashing method to use.
- ⚡ count controls the CPU time cost of the hash; the valid range and exact meaning of "CPU time cost" depend on the hashing method, but larger numbers produce more costly hashes.
- 🎲 rbytes should point to nrbytes cryptographically random bytes for use as "salt."
If prefix is a null pointer, the best available hashing method is selected.
⚠️ CAUTION: if prefix is an empty string, the "traditional" DES-based hashing method is selected — this method is unacceptably weak by modern standards.
If count is 0, a low default cost is selected. If rbytes is a null pointer, an appropriate number of random bytes is obtained from the operating system, and nrbytes is ignored.
See crypt(5) for other strings usable as prefix, and valid count values for each.
↩️ RETURN VALUES
The functions return a pointer to an encoded setting string. ✅
- 🔤 Entirely printable ASCII
- 🚫 Contains no whitespace
- 🚫 Contains none of the characters
:, ;, *, !, or \
See crypt(5) for more detail on the format. ❌ Upon error, they return a null pointer and set errno to an appropriate error code.
🧵 Thread / Memory Behavior
crypt_gensalt — places its result in a static storage area, overwritten by subsequent calls. ⚠️ Not safe to call from multiple threads simultaneously. ✅ Safe to pass directly to crypt without copying.
crypt_gensalt_rn — places its result in the supplied output buffer, which has output_size bytes available. output_size should be >= CRYPT_GENSALT_OUTPUT_SIZE. ✅ Thread-safe.
crypt_gensalt_ra — allocates memory for its result using malloc(3). 🧹 Free with free(3) after use. ✅ Thread-safe.
❌ Upon error, in addition to returning null, crypt_gensalt and crypt_gensalt_rn write an invalid setting string to their output buffer (if space allows); the string begins with * and is not equal to prefix.
⛔ ERRORS
- ❌
EINVAL — prefix is invalid or not supported by this implementation; count is invalid for the requested prefix; the input nrbytes is insufficient for the smallest valid salt with the requested prefix.
- ❌
ERANGE — crypt_gensalt_rn only: output_size is too small to hold the compiled setting string.
- ❌
ENOMEM — Failed to allocate internal scratch memory. crypt_gensalt_ra only: failed to allocate memory for the compiled setting string.
- ❌
ENOSYS, EACCES, EIO, etc. — Obtaining random bytes from the operating system failed. This can only happen when rbytes is a null pointer.
🧪 FEATURE TEST MACROS
The following macros are defined by <crypt.h>:
✅ CRYPT_GENSALT_IMPLEMENTS_DEFAULT_PREFIX
A null pointer can be specified as the prefix argument.
✅ CRYPT_GENSALT_IMPLEMENTS_AUTO_ENTROPY
A null pointer can be specified as the rbytes argument.
🌐 PORTABILITY NOTES
- 📦 The functions are not part of any standard. They originate with the Openwall project.
- ☀️ A function named
crypt_gensalt also exists on Solaris 10 and newer, but its prototype and semantics differ.
- 🚀 The default prefix and auto entropy features are available since libxcrypt version 4.0.0. Portable software should use feature test macros to determine if null pointers can be used for
prefix and rbytes.
- 🖥️ The set of supported hashing methods varies considerably from system to system.
🛡️ ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7).
Interface Attribute Value
crypt_gensaltThread safety MT-Unsafe race:crypt_gensalt ⚠️
crypt_gensalt_rn, crypt_gensalt_raThread safety MT-Safe ✅
🔗 SEE ALSO
crypt(3), getpass(3), getpwent(3), shadow(3), login(1), passwd(1), crypt(5), passwd(5), shadow(5), pam(8)
Openwall Project — October 11, 2017
Generated by phpman v4.9.26-5-g7740029 Author: Che Dong Under GNU General Public License
2026-08-14 20:49 @2600:1f28:365:80b0:4d23:66fa:c2bb:7bae
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)

