Converting values in a list to their hashed forms (Python)
Question: I currently have the following code:

    
    
    from itertools import permutations
    import hashlib
    
    def hash_f(x):
        h = hashlib.md5(x)
        return int(h.hexdigest(),base=16)
    
    value = raw_input("Enter a value: ")
    possibleValues = 'a'
    
    for p in permutations(possibleValues):
        if hash_f(value) == hash_f(possibleValues):
            print "MATCH"
    

(The import and use of permutations is a placeholder for now, it'll be used
more once this problem is solved)

What I would like to know is whether or not it's possible to iterate through a
list and replace its value with the hashed form of that value. Using my
current `hash_f(x)` function doesn't work with lists, which is the problem
here.

Thanks for advance for any help, and let me know if you need more information!


Answer: I'm not understanding what your snippet is supposed to do, but your question
seems like it could be answered with a list comprehension.

    
    
    from hashlib import md5
    
    input_list = ['a','b','c','d','e']
    
    hashed_list = [int(md5(x).hexdigest(), base=16) for x in input_list]
    
    # Do whatever you wanted to do with the list of hashes....
    

