def calc_hash(type, content):
 header = ('%s %d\x00' % (type, len(content)))
 sum = Sha1(header)
 sum.update(content)
 return sum.digest()

def calc_hash ( type , content ) : header = ( '%s %d\x00' % ( type , len ( content ) ) ) sum = Sha1 ( header ) sum . update ( content ) return sum . digest ( )
calculate some contents hash in the git fashion .