crypt_preferred_method(3)

crypt_preferred_method3

Get the prefix of the preferred hash method

Usage

#include <crypt.h>

const char*

crypt_preferred_method(void);

Library

library “libcrypt”

Overview

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

InterfaceAttributeValue
Thread safetyMT-Safe

Releases

4 releases since Debian 11 (Bullseye); the text changed 1 time.

  1. 11–13
  2. Arch

From libxcrypt 4.5.2-1 in Arch Linux 2026-11-01. Parsed by carta from the page's mdoc source.