def get_ha1_file_htdigest(filename):
 def get_ha1(realm, username):
  result = None
  f = open(filename, 'r')
  for line in f:
   (u, r, ha1) = line.rstrip().split(':')
   if ((u == username) and (r == realm)):
    result = ha1
    break
  f.close()
  return result
 return get_ha1

def get_ha1_file_htdigest ( filename ) : def get_ha1 ( realm , username ) : result = None f = open ( filename , 'r' ) for line in f : ( u , r , ha1 ) = line . rstrip ( ) . split ( ':' ) if ( ( u == username ) and ( r == realm ) ) : result = ha1 break f . close ( ) return result return get_ha1
returns a get_ha1 function which obtains a ha1 password hash from a flat file with lines of the same format as that produced by the apache htdigest utility .