Utils: Create a generic hash function for autotest

In order to get rid of md5/sha deprecation messages
when using python 2.6 and keeping 2.4 working, a
new function called utils.hash() was created: This
function abstracts the complexity of conditional
importing and can be used throughout autotest in
pretty much all the scenarios where an md5 or sha1
hash is needed.

The function returns a hash object, so if you want
the digest or hexdigest of the whole content you
need to explicitly call hexdigest(). This was made
because in some occasions we don't want to calculate
the digest straight away, rather we update the hash
with content until the point we can evaluate the
digest.

By the way, the name chosen does not clash with the
API of neither py 2.6 hashlib nor py 2.4 md5 or sha.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>


git-svn-id: http://test.kernel.org/svn/autotest/trunk@4203 592f7852-d20e-0410-864c-8624ca9c26a4
1 file changed