---
name: "crypt_preferred_method"
section: "3"
platform: "linux"
package: "libxcrypt"
version: "4.5.2-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/crypt_preferred_method"
---

# crypt\_preferred\_method(3)

get the prefix of the preferred hash method

## NAME

**crypt\_preferred\_method** – get the prefix of the preferred hash method

## LIBRARY

library “libcrypt”

## SYNOPSIS

**#include \<crypt.h\>**

*const* *char\**\

**crypt\_preferred\_method**(*void*);

## DESCRIPTION

**crypt\_preferred\_method** is a convenience function to get the prefix of the preferred hash method.  If a preferred method is available, it is the same as the one also used by the **crypt\_gensalt** **functions**, if their given *prefix* parameter is NULL.

## RETURN VALUES

The string returned equals the prefix of the preferred hash method. If no preferred hash method is available it is NULL. It *is* safe to pass the string returned by **crypt\_preferred\_method** directly to **crypt\_gensalt** without prior string-sanitizing nor NULL-pointer checks.

## 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.

## PORTABILITY NOTES

The function **crypt\_preferred\_method** is not part of any standard. It was added to libxcrypt in version 4.4.0.

## ATTRIBUTES

For an explanation of the terms used in this section, see [attributes(7)](/attributes/7.md).

| | | |
| --- | --- | --- |
| **Interface** | **Attribute** | **Value** |
|  | Thread safety | MT-Safe |

## SEE ALSO

[crypt\_gensalt(3)](/crypt_gensalt/3.md)
