mysql - Storing SSNs in a database -


i'm working on web application users need submit social security numbers.

i use asymmetric keys encryption if web server compromised private key still safe. application won't processed on webserver.

however app needs ability know if ssn duplicate not allow duplicates , b allow users come application.

can done? make sense use 1 way hash similar way passwords stored or compromise data?

thanks in advance.

-- edit

i'm adding question after thinking bit more it.

since there aprox. 10 billion ssns. make hashing alg. susceptible brute force attacks. salt here. if salt known isn't still susceptible brute force? possible hide salt since if has access database have access salt?

don't encrypt ssns, hash them

it sounds should hashing ssns rather encrypting them. difference between 2 hashing one-way while encryption not. don't need verify value of data, integrity, use hashing because

  1. hashing more secure encryption hashed ssns can not unhashed
  2. hashing still allows verify integrity of data , check duplicate ssns in database.

how hash

if you're using php 5 >= 5.5.0, strongly recommend using php's built in password hashing functions. it's battle tested , created situation. auto generates own secure salt (but still has option of providing own).

make sure read documentation on password hashing functions, short example (taken docs' example) below:

<?php // create password hash: $ssn = password_hash($ssn, password_default); // verify integrity of user entering // in example, $hash hashed password generated password_hash if (password_verify('rasmuslerdorf', $hash)) {     echo 'ssn valid!'; } else {     echo 'invalid ssn.'; } ?> 

remember check docs on password hashing functions correctly use them:


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -