vitalnix user management suite 3.2.0


Name

vxutil_genpw -- password generation

Syntax

#include <vitalnix/libvxutil/libvxutil.h>

void vxutil_genpw(char *password, int len, unsigned int flags);

Link with -lvxutil.

Description

vxutil_genpw() will generate a random password according to the parameters in the flags argument. len should denote the size of the buffer pointed to by password, so actually len-1 characters are produced.

Flags for characteristics:

GENPW_1DIGIT Make sure there is at least one digit in the output.
GENPW_O1DIGIT Allow digits to appear in the output password. If this flag is not present, no digits will ever be in the password.
GENPW_1CASE Make sure there is at least one uppercase character in the output.
GENPW_O1CASE Allow uppercase characters to appear in the output. If this flag is not present, no uppercase characters will ever be in the password.

Flags for algorithms:

Only one of the flags can be chosen at a time.

GENPW_RAND Generate a truly random password. This is the default.
GENPW_JP Generate a password from randomly chosen JP table (Hepburn romanization) indexes. See below for details.
GENPW_ZH Generate a password from randomly chosen ZH table (Pinyin romanization) indexes. See below for details.

Phonetic passwords

Because truly random passwords are harder to remember, Vitalnix comes with alternate algorithms that produce so-called phonetic passwords, that is, passwords that are random yet easily pronouncible (in Western culture at least) and memorizable.

ZH table

GENPW_ZH will choose an algorithm which randomly picks strings from a reduced table of simplified Pinyin romanization strings of Chinese hanzi. Similarly sounding pairs have been squashed to minimize decision problems when a person is recollecting the password from phonetic memory. The ZH table is quite versatile with 381 strings, so if you think the passwords are too complex (run vxrandpw(1) to put you to a test), try going with the JP table instead.

JP table

GENPW_JP will choose an algorithm which randomly picks strings from a table of Hepburn romanization strings of the Japanese base kana plus voiced variants (e.g. "HA", "BA" and "PA", but no combinations like "BYA"). The JP table consists of only 69 strings, so provides a pool of easy syllables. A few minor tweaks are in place to avoid corner cases such as the same string twice in a row, or two consecutive consonants (e.g. problematic "NRU").

Example

char buf[9];
vxutil_genpw(buf, sizeof(buf), GENPW_JP | GENPW_1DIGIT);

See also

vxrandpw(1)