Logo Search packages:      
Sourcecode: abakus version File versions  Download package

MD5.py

import imp
import string
file, name, desc=imp.find_module('md5')
try:
    md5=imp.load_module('md5', file, name, desc)
finally:
    if file:
        file.close()
def current(new, old):
    return new==old
def hexdigest(s):
    h=string.hexdigits
    r=''
    for c in s:
      i=ord(c)
      r=r + h[(i >> 4) & 0xF] + h[i & 0xF]
    return r
def collect(signatures):
    if len(signatures)==1:
      return signatures[0]
    else:
        contents=string.join(signatures, ', ')
      return hexdigest(md5.new(contents).digest())
def signature(obj):
    try:
        gc=obj.get_contents
    except AttributeError:
        raise AttributeError, "unable to fetch contents of '%s'" % str(obj)
    return hexdigest(md5.new(str(gc())).digest())
def to_string(signature):
    return signature
def from_string(string):
    return string

Generated by  Doxygen 1.6.0   Back to index