简体   繁体   中英

How to use crypt_gensalt() in crypt.h

According to crypt.h:

extern char *crypt_gensalt (const char *__prefix, unsigned long __count,
                            const char *__rbytes, int __nrbytes)

I understand that __prefix is encryption type (ie $2a$, $5$, $6$,...). My guess is __rbyte is the passphrase and __nrbytes is the size of passphrase. How about __count ? What should I pass into it? I'm going to use $6$ prefix.

From the man page: https://manpages.debian.org/experimental/libcrypt1-dev/crypt_gensalt_rn.3.en.html

count controls the CPU time cost of the hash; the valid range for count and the exact meaning of “CPU time cost” depends on the hashing method, but larger numbers correspond to more costly hashes.

See also https://manpages.debian.org/experimental/libcrypt1-dev/crypt.5.en.html

For $6$ (which is sha512crypt )

CPU time cost parameter
1000 to 999,999,999

and

The default CPU time cost parameter is 5000, which is too low for modern hardware.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM