【问题标题】:How to use crypt_gensalt() in crypt.h如何在 crypt.h 中使用 crypt_gensalt()
【发布时间】:2022-01-03 10:38:40
【问题描述】:

根据crypt.h:

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

我了解__prefix 是加密类型(即 $2a$、$5$、$6$、...)。我的猜测是 __rbyte 是密码,__nrbytes 是密码的大小。 __count 怎么样?我应该传入什么?我将使用$6$ 前缀。

【问题讨论】:

    标签: c crypt


    【解决方案1】:

    来自手册页:https://manpages.debian.org/experimental/libcrypt1-dev/crypt_gensalt_rn.3.en.html

    count控制哈希的CPU时间成本;计数的有效范围和“CPU 时间成本”的确切含义取决于散列方法,但较大的数字对应于更昂贵的散列。

    另见https://manpages.debian.org/experimental/libcrypt1-dev/crypt.5.en.html

    对于$6$(即sha512crypt)

    CPU时间成本参数
    1000 至 999,999,999

    和

    默认的 CPU 时间成本参数是 5000,这对于现代硬件来说太低了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-02
      • 2021-06-04
      • 2017-01-30
      相关资源
      最近更新 更多