Hashing Identifiers
Surfside accepts the following hashed identifiers and hashing types:
Email addresses: SHA-256, MD5, or SHA-1 hashes
Phone numbers: SHA-1 hashes (EU data files cannot contain hashed phone numbers)
Mobile device IDs: SHA-1 hashes
Hashing Email Addresses
Surfside accepts SHA-256, MD5, or SHA-1 hashed email addresses. See "Formatting Email Addresses" for more information.
Convert all characters to lowercase and remove all whitespace before hashing. For example, the plaintext email address "JohnDoe@surfside.io " must be changed to "johndoe@surfside.io" before hashing.
Caution
Make sure to check that your hashing algorithm produces the results for email address hashing produced in the “Hashing Examples” section of this document. Hashing algorithms that put a “0x” at the beginning of the hash string will result in the file upload failing.
Note
Your match rates may be slightly lower with hashed email addresses than with plaintext emails. To maximize the match rates for hashed email addresses, send all three hash types, each in a separate column.
See the "Hashing Examples" section below for specific hashing instructions and examples.
Hashing Examples
MD5 Hashing in Python
The following code snippet shows an example of how to perform an MD5 hash of an email address in Python.
# Import hashing library
import hashlib
# The input email has capital letters and a space at the end.
input_email = "JohnDoe@surfside.io "
# The input email address is downcased and ALL whitespace (not only spaces) is removed.
hashed_email = hashlib.md5(''.join(input_email.lower().split())).hexdigest()
SHA-1 Hashing in Ruby
The following code snippet shows an example of how to perform a SHA-1 hash of an email address in Ruby.
# Load the Digest module
require 'digest'
email_to_hash = 'surfside@example.com'
# Get the hex-encoded hash value (a.k.a. digest value) of the email address
# after stripping leading and trailing white space and replacing all uppercase
# letters with their lowercase counterparts.
Digest::SHA1.hexdigest(email_to_hash.strip.downcase)
#=> "91ac4ee2ca1782581f12d865a6779eb179f8b22a"
SHA-1 Hashing in Python
The following code snippet shows an example of how to perform an SHA-1 hash on a phone number in Python.
import hashlib
# A phone number in the correct format
input_phone = "4159870604"
# SHA-1 hash the phone number
hashed_phone = hashlib.sha1(input_phone).hexdigest()
Other Hashing Examples
There are JavaScript libraries available that can perform SHA-1 hashes.