def PBKDF2(password, salt, dkLen=16, count=1000, prf=None):
 password = tobytes(password)
 if (prf is None):
  prf = (lambda p, s: HMAC.new(p, s, SHA1).digest())
 key = b('')
 i = 1
 while (len(key) < dkLen):
  U = previousU = prf(password, (salt + struct.pack('>I', i)))
  for j in xrange((count - 1)):
   previousU = t = prf(password, previousU)
   U = strxor(U, t)
  key += U
  i = (i + 1)
 return key[:dkLen]

def PBKDF2 ( password , salt , dkLen = 16 , count = 1000 , prf = None ) : password = tobytes ( password ) if ( prf is None ) : prf = ( lambda p , s : HMAC . new ( p , s , SHA1 ) . digest ( ) ) key = b ( '' ) i = 1 while ( len ( key ) < dkLen ) : U = previousU = prf ( password , ( salt + struct . pack ( '>I' , i ) ) ) for j in xrange ( ( count - 1 ) ) : previousU = t = prf ( password , previousU ) U = strxor ( U , t ) key += U i = ( i + 1 ) return key [ : dkLen ]
derive one or more keys from a password .