使用 PHP crypt() 时,MySQL 中的密码应该使用什么字段类型

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23435929/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 16:43:40  来源:igfitidea点击:

What Field Type Should Be Used for Password in MySQL when Using PHP crypt()

phpmysqlcrypt

提问by Mona Coder

Using PHP crypt() method I have a PHP script to store users encrypted passwords in MySQL database. Can you please let me know what field type I should use to store the encrypted data?

使用 PHP crypt() 方法我有一个 PHP 脚本来将用户加密的密码存储在 MySQL 数据库中。你能告诉我应该使用什么字段类型来存储加密数据吗?

Thanks

谢谢

回答by wallyk

varchar(of sufficient length)

varchar(足够的长度)

回答by JParkinson1991

Use 'varchar'

使用“varchar”

In additon to wallyk's answer,
Exact lengths of encrytpted strings using crypt() are;

除了 wallyk 的回答之外,
使用 crypt() 加密的字符串的确切长度是;

Standard DES: stqAdD7zlbByI
Extended DES: _S4..someQXidlBpTUu6
MD5: $somethinNZKrUlY6r7K7.rdEOZ0w.
Blowfish: a$anexamplestringforsaleLouKejcjRlExmf1671qw3Khl49R3dfu
SHA-256: $rounds=5000$anexamplestringf$KIrctqsxo2wrPg5Ag/hs4jTi4PmoNKQUGWFXlVy9vu9
SHA-512: $rounds=5000$anexamplestringf$Oo0skOAdUFXkQxJpwzO05wgRHG0dhuaPBaOU/
         oNbGpCEKlf/7oVM5wn6AN0w2vwUgA0O24oLzGQpp1XKI6LLQ0. 

回答by A_Sandwich

It depends on what type of encryption you are using but varbinary is appropriate in some situations.

这取决于您使用的加密类型,但 varbinary 在某些情况下是合适的。