encryption - Storing scrambled Social Security numbers -


i need store social security number in unique scrambled state...

the reason: require social numbers, not want store them open in case if database gets compromised.

i want convert social security number string of alphanumerics , prefer one-way process.(not reversible)

then, when search existing ssn numbers, use same algorithm again user-input, scramble ssn , search database using alphanumeric string.

in php,

function maskssn($ssn) {     $salt = sha1(md5($ssn));     $scram = md5($ssn . $salt);     return $scram; } 

but not think produce unique values

if can store full hash (not truncated) shouldn't have collisions 9 digit ssn using secure hashes.

to keep hashes being brute forcible use hmac-sha1 or hmac-sha256 secret key. here related answer involved phone numbers , anonymizing data https://stackoverflow.com/a/15888989/637783

an aes-256 result wouldn't usable later out decryption, aes-256, , securely used, produces different results same input. however, used reasonably in relational table in ssn encrypted , stored against primary key other tables referencing key instead.

the later option allowed rotate keys pretty too, on time.


Comments

Popular posts from this blog

Java sticky instances of class com.mysql.jdbc.Field aggregating -