简体   繁体   English

将多个密码存储到数据库的最佳方法

[英]Best way to store multiple passwords into Database

In my database I've a field for the user password (User.UserPassword), I'm using SHA1 algorithm to hash the user input and then I hash it with a salt. 在我的数据库中,有一个用于输入用户密码(User.UserPassword)的字段,我正在使用SHA1算法对用户输入进行哈希处理,然后使用盐对其进行哈希处理。 Ok, that's fine. 好没问题。

But now I'm authenticating CIFS users too. 但是现在我也在对CIFS用户进行身份验证。 One protocol of CIFS is NTLMv1, which uses MD4 16 bits (very insecure) for my Samba Java Server. CIFS的一种协议是NTLMv1,它对我的​​Samba Java服务器使用16位MD4(非常不安全)。

I can't convert MD4 to SHA1 or compare those hash results. 我无法将MD4转换为SHA1或比较那些哈希结果。 So, I need to save two hashs or compare them. 因此,我需要保存两个哈希或比较它们。 So, I can: 因此,我可以:

  • Save the MD4 hash into User.UserPasswordMD4. 将MD4哈希保存到User.UserPasswordMD4中。

  • Save the MD4 hash into some other table, like ExternalAuthenticators 将MD4哈希保存到其他表中,例如ExternalAuthenticators

  • Save the user full text password and convert it (Blargh) 保存用户全文密码并进行转换(大)

  • Spring Security (I don't know how to do it, yet) Spring Security(我还不知道该怎么做)

  • Your option goes here... 您的选择在这里...

Can anyone help me? 谁能帮我?

Looks like you should store somewhere that RC4 hash, because both client and server should do the same actions on challenge bytes and than server should compare results. 看起来您应该将RC4哈希存储在某个地方,因为客户端和服务器都应对质询字节执行相同的操作,然后服务器应比较结果。

  • Saving plain text password - bad idea, forget about it. 保存纯文本密码-好主意,算了吧。
  • If you save it as PasswordMD4 in database - it not add security more then PC4 by self. 如果将其另存为Database4中的PasswordMD4,则其安全性仅次于PC4。
  • Saving in other table - no different with previous variant. 保存在其他表中-与以前的版本没有什么不同。
  • Spring security - don't know how it can be apply here. Spring安全性-不知道如何在这里应用。

You can store important or all DB data on encrypted partition, but it degrade performance a little. 您可以在加密分区上存储重要的数据库数据或所有数据库数据,但是这会稍微降低性能。

I can suggest store RC4 password into SHA-1 field, but encrypted. 我可以建议将RC4密码存储到SHA-1字段中,但应进行加密。 3DES will be enough, maybe with some salt. 3DES就足够了,也许要加些盐。 You already should have salt somewhere for your SHA-1 hash. 您已经应该在SHA-1哈希值的某处加盐。 When you need RC4 hash, simple decrypt value from DB, subtract (or XOR) salt and do usual authentication procedure. 当您需要RC4哈希时,可以简单地从数据库解密值,减去(或XOR)盐并执行常规的身份验证过程。

And don't use NTLM v1, it is old and unsecure. 而且不要使用NTLM v1,因为它太旧而且不安全。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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