CRYPT_PREFERRED_METHOD(3)
β¨ CRYPT_PREFERRED_METHOD(3) β¨
okay bestie, welcome to the crypt_preferred_method page π this is the CRYPT_PREFERRED_METHOD(3) manual page, living in the Library Functions Manual, and it's about to tell you how to find out which hash method your system is stanning rn. no cap, it's short, it's sweet, and it's lowkey iconic.
π NAME π
crypt_preferred_method β get the prefix of the preferred hash method
π LIBRARY π
Crypt Library (libcrypt, -lcrypt)
like, that's the library you gotta link against, periodt π«Ά
π¦ SYNOPSIS π¦
#include <crypt.h>
const char*
crypt_preferred_method(void);
π DESCRIPTION π
so crypt_preferred_method is a little convenience function β a lil helper bestie, doing the most so you don't have to β that gets you the prefix of the preferred hash method β¨
and here's the tea: if a preferred method is available, it's literally the same one that the crypt_gensalt functions use too, whenever their given prefix parameter is NULL. same vibe, same method, no drama.
πΈ RETURN VALUES πΈ
the string that comes back at you equals the prefix of the preferred hash method π« and if there's no preferred hash method available, it's NULL. that's it, that's the whole return situation.
now for the part that's giving safety: it is safe to pass the string returned by crypt_preferred_method directly to crypt_gensalt β no prior string-sanitizing needed, no NULL-pointer checks needed. just hand it over. slay π
π₯ FEATURE TEST MACROS π₯
<crypt.h> will define the macro CRYPT_PREFERRED_METHOD_AVAILABLE if crypt_preferred_method is available in the current version of libxcrypt.
so like, you can vibe-check whether the function even exists before you use it. iykyk π
π PORTABILITY NOTES π
real talk: the function crypt_preferred_method is not part of any standard. nope, not a single one. it was added to libxcrypt in version 4.4.0, so if you're on something older, this function is simply not in the group chat π
π ATTRIBUTES π
for an explanation of the terms used in this section, see attributes(7).
crypt_preferred_methodβ Thread safety:MT-Safe
that's the whole table bestie, and yes, MT-Safe means it's chill across threads π§
β SEE ALSO β
reminder boo: everything above is exactly as written in the original β i'm just the hype girl, not the source of truth π
libxcrypt β’ November 16, 2018 β ok that's the whole page, thanks for reading my lil manual-page era π«Ά go forth and get that preferred method prefix, you absolute main character π β¨π
π¦ where this page comes from
- arch rolling: libxcrypt 4.5.2-1 Β· LGPL
- fedora 43: libxcrypt-devel 4.4.38-8.fc43 Β· LGPL-2.1-or-later AND BSD-3-Clause AND BSD-2-Clause AND BSD-2-Clause-FreeBSD AND 0BSD AND CC0-1.0 AND LicenseRef-Fedora-Public-Domain
- fedora 43: libxcrypt-devel 4.4.38-8.fc43 Β· LGPL-2.1-or-later AND BSD-3-Clause AND BSD-2-Clause AND BSD-2-Clause-FreeBSD AND 0BSD AND CC0-1.0 AND LicenseRef-Fedora-Public-Domain
- fedora 43: libxcrypt-devel 4.5.2-1.fc43 Β· LGPL-2.1-or-later AND BSD-3-Clause AND BSD-2-Clause AND BSD-2-Clause-FreeBSD AND 0BSD AND CC0-1.0 AND LicenseRef-Fedora-Public-Domain
- fedora 43: libxcrypt-devel 4.5.2-1.fc43 Β· LGPL-2.1-or-later AND BSD-3-Clause AND BSD-2-Clause AND BSD-2-Clause-FreeBSD AND 0BSD AND CC0-1.0 AND LicenseRef-Fedora-Public-Domain
- fedora 44: libxcrypt-devel 4.5.2-3.fc44 Β· LGPL-2.1-or-later AND BSD-3-Clause AND BSD-2-Clause AND BSD-2-Clause-FreeBSD AND 0BSD AND CC0-1.0 AND LicenseRef-Fedora-Public-Domain
- fedora 44: libxcrypt-devel 4.5.2-3.fc44 Β· LGPL-2.1-or-later AND BSD-3-Clause AND BSD-2-Clause AND BSD-2-Clause-FreeBSD AND 0BSD AND CC0-1.0 AND LicenseRef-Fedora-Public-Domain
- nixpkgs unstable: libxcrypt 4.5.2
- ubuntu resolute: libcrypt-dev 1:4.5.1-1
- ubuntu stonking: libcrypt-dev 1:4.5.2+20251210-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms