- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
如何在Python 3中实现crypt选项?
我理解的用途是:
Hash = crypt.crypt(password, salt)
但是,该函数有一组不同的散列函数。来自文档:
crypt.METHOD_SHA512 A Modular Crypt Format method with 16 character salt and 86 character hash. This is the strongest method.
crypt.METHOD_SHA256 Another Modular Crypt Format method with 16 character salt and 43 character hash.
crypt.METHOD_MD5 Another Modular Crypt Format method with 8 character salt and 22 character hash.
crypt.METHOD_CRYPT The traditional method with a 2 character salt and 13 characters of hash. This is the weakest method.
我的问题是如何选择函数使用的算法?
这是一个非常基本的问题,我不敢相信我自己找不到答案 - 如果我浪费了你的时间,我深表歉意。
最佳答案
您将方法作为盐参数传递。来自crypt function docstring :
If
salt
is not specified or isNone
, the strongest available method will be selected and a salt generated. Otherwise,salt
may be one of thecrypt.METHOD_*
values, or a string as returned bycrypt.mksalt()
.
例如:
crypt.crypt("password", crypt.METHOD_SHA512)
引擎盖下变成了:
crypt.crypt("password", crypt.mksalt(crypt.METHOD_SHA512))
关于Crypt 函数的 Python 用法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41887491/
我正在将一些 C 代码从 Linux 迁移到 Mac OSX (yosemite)。 Mac OSX crypt() 函数(在 unistd.h 中,正如我所确定的)与 Linux 中的 gcc/gn
我确实对 crypt() PHP 函数感到困惑。 当第二个 crypt 显然使用不同的第二个参数时,以下两个 crypt 函数如何给出相同的输出?差异盐意味着差异哈希对吗? echo crypt("p
我正在为 CS50 做第 2 周的 pset。 使用 crypt 函数时,指向任何字符串密文的 char 指针总是指向我加密的最后一个东西。 例如: char password[] = "AAAA";
我已经使用 c 中的 crypt 函数来加密给定的字符串。我写了下面的代码, #include #include int main() { printf("%s\n",crypt("passw
我正在比较 PHP 的 crypt() 与 Python 的 crypt()。来自阅读 Python 手册: http://docs.python.org/2/library/crypt.html P
我正在比较 PHP 的 crypt() 与 Python 的 crypt()。来自阅读 Python 手册: http://docs.python.org/2/library/crypt.html P
出于某种原因,无论我尝试什么,使用crypt模块都会使用13字符哈希而不是sha-512。我见过无数关于问题的问题,但没有一个符合我的。难道就没有办法改变 crypt 方法吗? >>> import
我想用 crypt 散列密码使用 blowfish 加密的模块。 在 Fedora 29 上我得到了正确的结果: $ python3.7 Python 3.7.2 (default, Jan 3 2
我目前正在研究 Violent Python 一书中的一个示例。你可以看到我的实现 here 我现在正尝试在 Go 中实现相同的脚本来比较性能,注意我是 Go 的新手。打开文件并遍历这些行很好,但是我
背景 crypt 有两个定义,from the docs, 其中一个使用 unistd.h #define _XOPEN_SOURCE /* See feature_test_macros
我使用 dovecot 作为我的邮件传输代理,我的目标是使用 strongest password scheme我的系统支持:SHA512-CRYPT 或 SHA256-CRYPT(BLF-CRYPT
我正在学习 Python。我不明白为什么 hashlib.sha512(salt + password).hexdigest() 没有给出预期的结果。 我正在寻找与 Ulrich Drepper 的
我正在使用 GCC 4.6.0(在一个其他身份不明的平台上)。 我正在使用 crypt() 函数来加密密码。 我以前从未使用过该功能,所以我查看了主页: man 3 crypt 它说要包含 unist
我正在为 Linux 上的 MD5 哈希方案编写一个基本的密码破解程序 /etc/shadow file 。当我使用commons.codec时的DigestUtils或Crypt库,它们的哈希长度是
我更喜欢在 php 中使用 crypt 函数来进行密码加密和其他单向加密要求。因为我可以使用任何受支持的加密算法,通过更改 salt 并且几乎没有其他优势。通常,我不使用任何盐,它使用随机的 MD5
我有点困惑。当我用盐和密码调用 crypt 时,返回的字符串称为哈希或摘要?我很困惑,因为我知道从加密函数返回的内容称为哈希。但是当我们调用crypt 我们也传递 salt 作为参数。我们可以这样说:
本文整理了Java中freenet.crypt.Yarrow类的一些代码示例,展示了Yarrow类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些
我正在做一个练习,其中我需要将字符串中的字母替换为另一个字母(字母表中它前面的第四个字母)。我还必须消除除空格之外的所有非字母字符(“”)。到目前为止,我能够完成第一步(消除字符),但我无法替换字母。
我正在为我的网站创建我的更改密码网站,我的代码有一些问题...... 出于某种原因,我很难在加密后在数据库中比较和替换密码。 我想要这个: 获取当前用户密码并将其与 $oldpass 的输入值进行比较
当我使用 MD5 时,我曾经在数据库中创建一个 varchar(32) 列。但是,我开始使用 crypt(),据我所知,输出长度是可变的。那么我应该为 varchar 设置哪个长度? 最佳答案 返回的
我是一名优秀的程序员,十分优秀!