Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class SHA1Field(BaseField):
- """A field that validates input as resembling an SHA1 hash.
- """
- hash_length = 40
- def validate(self, value):
- if len(value) != SHA1Field.hash_length:
- raise DictPunch('SHA1 value is wrong length')
- try:
- x = int(value, 16)
- except:
- raise DictPunch('SHA1 value is not hex')
Add Comment
Please, Sign In to add comment