
from hashlib import sha1

def makeSha1(seq, verbose=False):
    h = sha1()
    if verbose: print 'Partial result:'
    if isinstance(seq, str):
        seq = [seq]
    for s in seq:
        if verbose: print h.hexdigest()
        h.update(s)
    return h.hexdigest()

def sha1Test():
    seq = ('Hello, this is a test of the Python implementation of SHA1.\n',
           '  This is more to add to the string.', '   And now done.')
    
    h1 = makeSha1(seq, True)
    print 'SHA1 from listed strings:', h1              
    h2 = makeSha1(''.join(seq), True)
    print 'SHA1 from concatenation :', h2              
    if h1 != h2:
        print 'Does not match'
    else:
        print 'Hashes match'
        
sha1Test()
