示例#1
0
    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)
示例#2
0
 def password_salt(self, password_salt):
     self._password_salt = _auth_utils.validate_bytes(
         password_salt, 'password_salt')
示例#3
0
 def _hmac(cls, name, key):
     data = {
         'signerKey':
         b64_encode(_auth_utils.validate_bytes(key, 'key', required=True))
     }
     return UserImportHash(name, data)
示例#4
0
 def password_hash(self, password_hash):
     self._password_hash = _auth_utils.validate_bytes(
         password_hash, 'password_hash')