--- a/VirtualMailManager/password.py Sat Feb 15 23:38:27 2014 +0000
+++ b/VirtualMailManager/password.py Sun Feb 16 23:07:30 2014 +0000
@@ -13,9 +13,11 @@
random_password = randompw()
scheme, encoding = verify_scheme(scheme)
schemes, encodings = list_schemes()
+ scheme = extract_scheme(hashed_password)
"""
import hashlib
+import re
from base64 import b64encode
from binascii import b2a_hex
@@ -309,6 +311,17 @@
}
+def extract_scheme(password_hash):
+ """Returns the extracted password scheme from *password_hash*.
+
+ If the scheme couldn't be extracted, **None** will be returned.
+ """
+ scheme = re.match(r'^\{([^\}]{3,37})\}', password_hash)
+ if scheme:
+ return scheme.groups()[0]
+ return scheme
+
+
def list_schemes():
"""Returns the tuple (schemes, encodings).