Skip to content
Snippets Groups Projects
Commit 5e601182 authored by Marco De Donno's avatar Marco De Donno
Browse files

Add the possibility to return only the PBKDF2 hash instead of the full string

parent 60c0f2bd
No related branches found
No related tags found
No related merge requests found
......@@ -30,12 +30,14 @@ class pbkdf2( object ):
self.stored_hash = None
self.h = None
def hash( self ):
def hash( self, hash_only = False ):
h = hashlib.pbkdf2_hmac( self.hash_name, self.word, self.salt, self.iterations )
h = binascii.hexlify( h )
r = "$".join( map( str, [ "pbkdf2", self.hash_name, self.salt, self.iterations, h ] ) )
return r
if hash_only:
return h
else:
return "$".join( map( str, [ "pbkdf2", self.hash_name, self.salt, self.iterations, h ] ) )
def verify( self ):
return self.stored_hash == self.hash()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment