Hash to display email
I use an e-mail generator to power the "E-mail address" box in my Contact Information section. This has a few advantages over the most common ways of showing email addresses (either plain text, or written with words like 'AT' and 'DOT', or displayed as an image):
- The email address is not written in plain text, so it is harder for spammers to algorithmically collect. It is—in principle—cryptographically secure; as secure as the hash function you use, anyway.
- Upon receiving correct input, it displays an email link which can be clicked or copy-and-pasted.
The script computes the md5 hash of the input (two hashes, actually), and compares this with a value stored in the script. The md5 hash is a function which takes arbitrary strings of words as inputs, and returns a 32-digit hexadecimal number that has no apparent relationship to the input. This way, even though the script doesn't know the password, it can tell when the input is right! If it is, then the script returns the corresponding e-mail address. If not, then you get a little error message.
- Save the file email-display-functions.js
- Put the html code on your webpage. (Copy it from the demo below.)
- Include the two .js files in your html header.
- At this point, you should have a working version of the demo shown below—test it.
- Modify email-display-functions.js so that it returns your email address (3 steps described at the beginning of the file).
- Modify the html code as you please.
This box is a working demo. It will return a demo email address if given the input string 'hashtest'.
Fill in the correct input to reveal an email address.
For more information, see the
This box just shows the hash value of its input. You can use it to get the value of 'myHash' for your input string.