Guest User

Untitled

a guest
Jun 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. class SHA1Field(BaseField):
  2. """A field that validates input as resembling an SHA1 hash.
  3. """
  4. hash_length = 40
  5.  
  6. def validate(self, value):
  7. if len(value) != SHA1Field.hash_length:
  8. raise DictPunch('SHA1 value is wrong length')
  9. try:
  10. x = int(value, 16)
  11. except:
  12. raise DictPunch('SHA1 value is not hex')
Add Comment
Please, Sign In to add comment