schematics_extender.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:openregistry.api 作者: openprocurement 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号