本文介绍了将SSN作为MySQL的关键之一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类似于以下的问题:

I have a problem similar to the following:

一个人开始担任A公司顾问。他们的人力资源人员为他们设置了一个帐户。为人表和个人公司中的人创建了一个记录。

A person begins working as a consultant for "Company A". Their HR person sets up an account for them. A record is created for the person in a "person" table and a "person-company" one.

该人还在为B公司(该公司A可能或可能不知道)。当公司B进入他们的信息时,他们不应该在个人中创建记录,但应该在个人公司中创建一个记录。

The person is also working for "Company B" (which Company A may or may not know about). When Company B enters their info they should NOT create a record in "person" but SHOULD create one in "person-company".

该人员必须接受培训国家,所以如果他们在进行培训时登录到任一公司的网站,我们希望总共有几个小时留在该人身上。

The person is required to do training for the state, so if they are logged into either company's site when they do the training, we want the total hours to remain with the person.

我可以设置一个PK对于人员表,将他们加入到每个公司,但我认为我需要一些类似于该人的SSN的哈希,并附加一些额外的xyz,以便能够进行查找。公司B将为该人员提供SSN,这应该是通用的。

I can set up a PK for the person table the joins them to each company, but I think I need something like a hash of the person's SSN with some extra "xyz" tacked on to be able to do a lookup. Company B would have the SSN for the person, which should be universal.

问题:

1)是有一些其他的方法加入你认为会更好的工作?

1) Is there some other method to join that one of you think would work better?

2)如果我用散列SSN方法去做,什么是最好的加密用于MySQL / PHP用于单向加密?

2) If I do go with a hashed SSN approach, what's the best encryption to use for MySQL/PHP for one-way encryption?

我在其他地方阅读了一个公钥/私钥解决方案可能是最好的,但是由于该人最初没有建立自己的帐户

I read elsewhere that a public/private key solution may be best, but since the person is not setting up their own account initially I'm not sure how this would work.


推荐答案

我认为可能非常相关你在做什么如果您确实希望以安全方面的理由和法律责任匿名SSN,那么简单的散列是不够的。

I think this article may be very relevant to what you are doing. If indeed you wish to "anonymize" the SSNs for security reasons and legal liability, then simply hashing them is not enough.

只是散列它们将是一个完全确定性的过程,所以要有效地掩盖个别的SSN,这个过程需要随机化。否则,你可以通过所有可能的SSN组合来简单地强制执行(这比尝试强制哈希函数要少得多的工作),并寻找一个匹配的值。

Just hashing them would be a completely deterministic process, so to effectively "mask" individual SSNs, the process needs to be randomized. Otherwise you could simply brute force through all possible combinations of SSNs (which would be much less work required than trying to brute force the hash function) and look for a matching value.

为了看看为什么这样做是最简单的例子,一个SSN可以接受两个值0和1.不管哈希函数的质量和实力如何,最终只有两个可能的结果,很容易看看哪个是哪个。

To see why this holds take the most simplistic example that a SSN could just take on two values, 0 and 1. Regardless of the quality and strength of the hash function, in the end there will only be two possible outcomes and it's easy to see which is which.

这是老游戏为什么你不应该哈希直接密码,而不对其进行一些预处理。基础数据不包含足够的熵,因此将成为预先计算表中查找的简单目标。

It's the old game of why you shouldn't hash e.g. passwords directly without performing some preprocessing on them first. The underlying data just doesn't contain enough entropy and will therefore be an easy target for lookups in a precomputed table.

您的SSN成为私人和机密的时刻(他们是不是在每个国家,所以原谅我的愚蠢的问题在评论:),同样的最佳做法也用于密码存储也应该适用于你的具体情况,即缓慢的自适应散列算法补偿缺乏初始熵例如bcrypt,scrypt和PBKDF2(已由Marcus Adams推荐)。

The minute your SSNs become private and confidential (they are not in every country, so forgive my stupid question in the comments :), the same best practices that are also used for password storage should also be applicable to your particular case, i.e. a slow adaptive hashing algorithm that compensates for the lack of initial entropy such as bcrypt, scrypt and PBKDF2 (which was already recommended by Marcus Adams).

这篇关于将SSN作为MySQL的关键之一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 12:05