def __init__(self, type=None, type_d=False, version=None, memory_cost=None, data=None, **kwds): # handle deprecated kwds if type_d: warn( 'argon2 `type_d=True` keyword is deprecated, and will be removed in passlib 2.0; ' 'please use ``type="d"`` instead') assert type is None type = TYPE_D # TODO: factor out variable checksum size support into a mixin. # set checksum size to specific value before _norm_checksum() is called checksum = kwds.get("checksum") if checksum is not None: self.checksum_size = len(checksum) # call parent super(_Argon2Common, self).__init__(**kwds) # init type if type is None: assert uh.validate_default_value(self, self.type, self._norm_type, param="type") else: self.type = self._norm_type(type) # init version if version is None: assert uh.validate_default_value(self, self.version, self._norm_version, param="version") else: self.version = self._norm_version(version) # init memory cost if memory_cost is None: assert uh.validate_default_value(self, self.memory_cost, self._norm_memory_cost, param="memory_cost") else: self.memory_cost = self._norm_memory_cost(memory_cost) # init data if data is None: assert self.data is None else: if not isinstance(data, bytes): raise uh.exc.ExpectedTypeError(data, "bytes", "data") self.data = data
def __init__(self, type_d=False, version=None, memory_cost=None, data=None, **kwds): # TODO: factor out variable checksum size support into a mixin. # set checksum size to specific value before _norm_checksum() is called checksum = kwds.get("checksum") if checksum is not None: self.checksum_size = len(checksum) # call parent super(_Argon2Common, self).__init__(**kwds) # init type # NOTE: we don't support *generating* type I hashes, but do support verifying them. self.type_d = type_d # init version if version is None: assert uh.validate_default_value(self, self.version, self._norm_version, param="version") else: self.version = self._norm_version(version) # init memory cost if memory_cost is None: assert uh.validate_default_value(self, self.memory_cost, self._norm_memory_cost, param="memory_cost") else: self.memory_cost = self._norm_memory_cost(memory_cost) # init data if data is None: assert self.data is None else: if not isinstance(data, bytes): raise uh.exc.ExpectedTypeError(data, "bytes", "data") self.data = data
def __init__(self, block_size=None, **kwds): super(scrypt, self).__init__(**kwds) # init block size if block_size is None: assert uh.validate_default_value(self, self.block_size, self._norm_block_size, param="block_size") else: self.block_size = self._norm_block_size(block_size)