0

I've a simple contact page where the user insert only the email address, to avoid double post I thought to create a simple sqlite3 db with just one field with unique constrain to save the email hash (I don't want to keep plain email address in this db)

A valid email max length is still 254?

(I know already about alternatives for double post problem)

My knowledge of math is limited, what would be a reasonable good hash to avoid collisions?

Community
  • 1
  • 1
Alex
  • 3,264
  • 1
  • 25
  • 40
  • It's a weird solution to prevent double posting. Just disable the button after it was clicked. – zerkms Aug 23 '15 at 23:44
  • @zerkms just a variant where the email hash is the *unique transaction id* itself, I know about [disabling](http://stackoverflow.com/a/4473801/2498790) but the user may want to register multiple valid address – Alex Aug 23 '15 at 23:47
  • Overhead for nothing, with this solution I don't even need javascript, just a couple of php rows – Alex Aug 23 '15 at 23:51

1 Answers1

5

You could use the sha512 hashing algorythm, as you're rather not to expect any collisions there, eg.:

$hash = hash('sha512', $myEmailAdress);
Community
  • 1
  • 1
Zepporle
  • 413
  • 4
  • 13