MySQL 如何在mysql中创建带有密码字段的表?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7522373/
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-31 21:08:44  来源:igfitidea点击:

How to create tables with password fields in mysql?

mysql

提问by Genadinik

Should I create the password column as a regular varchar and then insert like this:

我是否应该将密码列创建为常规 varchar,然后像这样插入:

sha1($pass_string)

Or should I do something extra upon the creation of the table to make sure that password field is secure?

或者我应该在创建表时做一些额外的事情以确保密码字段是安全的?

Thanks!

谢谢!

采纳答案by ykatchou

It's a normal varchar field (40 characters) but if you want to set it more secure you should use salt.

这是一个普通的 varchar 字段(40 个字符),但如果您想将其设置得更安全,则应使用 salt。

http://highedwebtech.com/2008/04/25/season-your-passwords-with-some-salt/

http://highedwebtech.com/2008/04/25/season-your-passwords-with-some-salt/

Update :

更新 :

WARNING : Hash password without salt is REALLY WEAK ! You should never use it !!

警告:没有盐的散列密码真的很弱!你永远不应该使用它!!

Password salting is the good way for doing it : password salting

密码加盐是这样做的好方法: 密码加盐

as adviced by pst :

根据 pst 的建议:

  • using SHA-1 and salt is the more naive but quite well secure approach.

  • using bcrypt:

  • 使用 SHA-1 和 salt 是更天真但非常安全的方法。

  • 使用bcrypt

it's the more secure approach :) because it use speed in order to make it more secure, bfish is a hash function built around the encryption method blowfish. (Seems than twofish exists too and should be the "modern" version of blowfish).

这是更安全的方法 :) 因为它使用速度来使其更安全,bfish 是围绕加密方法 bfish 构建的哈希函数。(似乎双鱼也存在,应该是河豚的“现代”版本)。

It's a version using a chain of SHA-1 so it's a intermediate solution, but allowing to set speed to your needs. In fact speed make weaker your security.

这是一个使用 SHA-1 链的版本,因此它是一个中间解决方案,但允许根据您的需要设置速度。事实上,速度会使您的安全性变弱。

回答by JM4

You could also use the AES_ENCRYPT() function built into mysql for greater security. Link here

您还可以使用 mysql 内置的 AES_ENCRYPT() 函数来提高安全性。 链接在这里

There is also a good how-to here explaining further: link

这里还有一个很好的操作方法,进一步解释:链接

回答by Michael Mior

The manualcontains a good explanation of what type of column to use.

该手册很好地解释了要使用的色谱柱类型。

回答by Bohemian

Most people save the hash as you have suggested. It's safe enough and simple, making it a good choice.

大多数人按照您的建议保存哈希。它足够安全和​​简单,是一个不错的选择。

Note that all hashes can be cracked eventually, so any hash is better than none and SHA is strong enough.

请注意,所有散列最终都可以被破解,因此任何散列总比没有好,而且 SHA 足够强大。