summaryrefslogtreecommitdiff
path: root/passlib/handlers/postgres.py
diff options
context:
space:
mode:
Diffstat (limited to 'passlib/handlers/postgres.py')
-rw-r--r--passlib/handlers/postgres.py41
1 files changed, 20 insertions, 21 deletions
diff --git a/passlib/handlers/postgres.py b/passlib/handlers/postgres.py
index 1324d83..b8683dd 100644
--- a/passlib/handlers/postgres.py
+++ b/passlib/handlers/postgres.py
@@ -1,26 +1,25 @@
"""passlib.handlers.postgres_md5 - MD5-based algorithm used by Postgres for pg_shadow table"""
-#=========================================================
-#imports
-#=========================================================
-#core
+#=============================================================================
+# imports
+#=============================================================================
+# core
from hashlib import md5
import re
import logging; log = logging.getLogger(__name__)
from warnings import warn
-#site
-#libs
-#pkg
+# site
+# pkg
from passlib.utils import to_bytes
from passlib.utils.compat import b, bytes, str_to_uascii, unicode, u
import passlib.utils.handlers as uh
-#local
+# local
__all__ = [
"postgres_md5",
]
-#=========================================================
-#handler
-#=========================================================
+#=============================================================================
+# handler
+#=============================================================================
class postgres_md5(uh.HasUserContext, uh.StaticHandler):
"""This class implements the Postgres MD5 Password hash, and follows the :ref:`password-hash-api`.
@@ -32,27 +31,27 @@ class postgres_md5(uh.HasUserContext, uh.StaticHandler):
:type user: str
:param user: name of postgres user account this password is associated with.
"""
- #=========================================================
+ #===================================================================
# algorithm information
- #=========================================================
+ #===================================================================
name = "postgres_md5"
_hash_prefix = u("md5")
checksum_chars = uh.HEX_CHARS
checksum_size = 32
- #=========================================================
+ #===================================================================
# primary interface
- #=========================================================
+ #===================================================================
def _calc_checksum(self, secret):
if isinstance(secret, unicode):
secret = secret.encode("utf-8")
user = to_bytes(self.user, "utf-8", param="user")
return str_to_uascii(md5(secret + user).hexdigest())
- #=========================================================
- #eoc
- #=========================================================
+ #===================================================================
+ # eoc
+ #===================================================================
-#=========================================================
-#eof
-#=========================================================
+#=============================================================================
+# eof
+#=============================================================================