def standard_scrypt(cls, memory_cost, parallelization, block_size, derived_key_length): """Creates a new standard Scrypt algorithm instance. Args: memory_cost: Memory cost as a non-negaive integer. parallelization: Parallelization as a non-negative integer. block_size: Block size as a non-negative integer. derived_key_length: Derived key length as a non-negative integer. Returns: UserImportHash: A new ``UserImportHash``. """ data = { 'memoryCost': _auth_utils.validate_int(memory_cost, 'memory_cost', low=0), 'parallelization': _auth_utils.validate_int(parallelization, 'parallelization', low=0), 'blockSize': _auth_utils.validate_int(block_size, 'block_size', low=0), 'dkLen': _auth_utils.validate_int(derived_key_length, 'derived_key_length', low=0), } return UserImportHash('STANDARD_SCRYPT', data)
def scrypt(cls, key, rounds, memory_cost, salt_separator=None): """Creates a new Scrypt algorithm instance. This is the modified Scrypt algorithm used by Firebase Auth. See ``standard_scrypt()`` function for the standard Scrypt algorith, Args: key: Signer key as a byte sequence. rounds: Number of rounds. Must be an integer between 1 and 8. memory_cost: Memory cost as an integer between 1 and 14. salt_separator: Salt separator as a byte sequence (optional). Returns: UserImportHash: A new ``UserImportHash``. """ data = { 'signerKey': b64_encode(_auth_utils.validate_bytes(key, 'key', required=True)), 'rounds': _auth_utils.validate_int(rounds, 'rounds', 1, 8), 'memoryCost': _auth_utils.validate_int(memory_cost, 'memory_cost', 1, 14), } if salt_separator: data['saltSeparator'] = b64_encode( _auth_utils.validate_bytes(salt_separator, 'salt_separator')) return UserImportHash('SCRYPT', data)
def pbkdf2_sha256(cls, rounds): """Creates a new PBKDF2 SHA256 algorithm instance. Args: rounds: Number of rounds. Must be an integer between 0 and 120000. Returns: UserImportHash: A new ``UserImportHash``. """ return UserImportHash( 'PBKDF2_SHA256', {'rounds': _auth_utils.validate_int(rounds, 'rounds', 0, 120000)})
def sha512(cls, rounds): """Creates a new SHA512 algorithm instance. Args: rounds: Number of rounds. Must be an integer between 1 and 8192. Returns: UserImportHash: A new ``UserImportHash``. """ return UserImportHash( 'SHA512', {'rounds': _auth_utils.validate_int(rounds, 'rounds', 1, 8192)})
def md5(cls, rounds): """Creates a new MD5 algorithm instance. Args: rounds: Number of rounds. Must be an integer between 0 and 8192. Returns: UserImportHash: A new ``UserImportHash``. """ return UserImportHash( 'MD5', {'rounds': _auth_utils.validate_int(rounds, 'rounds', 0, 8192)})
def _basic_hash(cls, name, rounds): data = { 'rounds': _auth_utils.validate_int(rounds, 'rounds', 0, 120000) } return UserImportHash(name, data)