Added hexdump, and also made the ValidateHash check work (if you pass it proper values, of course)

This commit is contained in:
Alex Marshall 2009-06-12 13:00:03 -07:00
parent 87851bdf33
commit 303e0c379e

View File

@ -7,6 +7,9 @@ from Struct import Struct
def align(x, boundary): def align(x, boundary):
return x + (x % boundary) return x + (x % boundary)
def hexdump(s,sep=" "):
return sep.join(map(lambda x: "%02x"%ord(x),s))
class Crypto: class Crypto:
"""This is a Cryptographic/hash class used to abstract away things (to make changes easier)""" """This is a Cryptographic/hash class used to abstract away things (to make changes easier)"""
def __init__(self): def __init__(self):
@ -21,7 +24,7 @@ class Crypto:
def ValidateHash(self, data, hash): def ValidateHash(self, data, hash):
"""Validates a hash. (BROKEN)""" """Validates a hash. (BROKEN)"""
return 1 #hack return 1 #hack
# if(hashlib.sha1(data).digest() == hash): # if(hashlib.sha1(data).hexdigest() == hexdump(hash, "")):
# return 1 # return 1
# else: # else:
# return 0 # return 0