Skip to content

Instantly share code, notes, and snippets.

@c0ldlimit
Created October 10, 2015 03:58
Show Gist options
  • Select an option

  • Save c0ldlimit/923089083b5c603397d0 to your computer and use it in GitHub Desktop.

Select an option

Save c0ldlimit/923089083b5c603397d0 to your computer and use it in GitHub Desktop.

Revisions

  1. c0ldlimit created this gist Oct 10, 2015.
    16 changes: 16 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    import base64
    import uuid
    import hashlib

    def hash_password(password, salt=None):
    if salt is None:
    salt = uuid.uuid4().hex

    hashed_password = hashlib.sha512(password + salt).hexdigest()

    return (hashed_password, salt)

    def verify_password(password, hashed_password, salt):
    re_hashed, salt = hash_password(password, salt)

    return re_hashed == hashed_password