from misc import *
import crypt

def words_in_line(l):
    raise Failure("to be written")

def streamify(f):
    raise Failure("to be written")

### uncomment the following when you have everything working!
#words_in_file = compose(streamify(words_in_line),open)

### put your transformation code here
# transformed_words_in_file=

def crack_pass_file(fn_pass,fn_words,fn_out):
    """Crack as many passwords in file fn_pass as possible using words
       in transformed_words_in_file(fn_words)"""
    ts=[l.split(":") for l in open(fn_pass,"r")]
    pw=[(t[0],t[1]) for t in ts]
    fout=open(fn_out,"w")
    for w in transformed_words_in_file(fn_words):
        for a,p in pw:
            if crypt.crypt(w,p)==p:
                fout.write("%s=%s\n" % (a,w))
                fout.flush()
    fout.close()

