def to_native(self, value, context=None):
value = super(HashType, self).to_native(value, context)
if ':' not in value:
raise ValidationError(self.messages['hash_invalid'])
hash_type, hash_value = value.split(':', 1)
if hash_type not in algorithms:
raise ValidationError(self.messages['hash_invalid'])
if len(hash_value) != hash_new(hash_type).digest_size * 2:
raise ValidationError(self.messages['hash_length'])
try:
int(hash_value, 16)
except ValueError:
raise ConversionError(self.messages['hash_hex'])
return value
schematics_extender.py 文件源码
python
阅读 35
收藏 0
点赞 0
评论 0
评论列表
文章目录