Skip to content

Instantly share code, notes, and snippets.

@Rorosha
Created September 13, 2012 15:59
Show Gist options
  • Save Rorosha/3715323 to your computer and use it in GitHub Desktop.
Save Rorosha/3715323 to your computer and use it in GitHub Desktop.
Basic Utility Functions
def email_check(email):
"""Checks to make sure user inputted email actually conforms to what an
email should look like. Returns True if everything looks right."""
try:
pieces = email.split('@')
if ' ' not in pieces[0] and '.' in pieces[1]:
return True
except:
return False
def pw_hash(pw):
"""Takes a string, and creates and returns a hexdigest. Keeps us from needing
to store actual passwords..."""
import hashlib
pw_digest = hashlib.new('sha1')
pw_digest.update(str(pw))
return pw_digest.hexdigest()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment