hyb
2025-11-04 668edf874b4f77214a8ff4513e60e3c1a973f532
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
Ë
Žñúh‡"ãó—ddlmZddlZddlmZmZddlmZmZm    Z    m
Z
ddl m Z ddl mZmZmZddlmZe«Zej(Zej,Zej0Zej4Zej8Zd d    „ZGd
„d «Zy) é)Ú annotationsN)ÚClassVarÚLiteralé)Ú
ParametersÚ _check_typesÚextract_parametersÚvalidate_params_for_platform)ÚInvalidHashError)ÚTypeÚ hash_secretÚ verify_secret)Úget_default_parameterscóH—t|t«r|S|j|«S)zM
    Ensure *s* is a bytes string.  Encode using *encoding* if it isn't.
    )Ú
isinstanceÚbytesÚencode)ÚsÚencodings  úJH:\Change_password\venv_build\Lib\site-packages\argon2/_password_hasher.pyÚ _ensure_bytesrs"€ô!”UÔØˆØ 8‰8HÓ Ðócón—eZdZUdZddgZded<ded<eeee    e
de jf                                                    dd„Z edd„«Zedd    „«Zedd
„«Zedd „«Zedd „«Zedd „«Zedd„«Zddœdd„Ze j0e j2e jdœZded<                        dd„Zdd„Zy)ÚPasswordHashera¯
    High level class to hash passwords with sensible defaults.
 
    Uses Argon2\ **id** by default and uses a random salt_ for hashing. But it
    can verify any type of Argon2 as long as the hash is correctly encoded.
 
    The reason for this being a class is both for convenience to carry
    parameters and to verify the parameters only *once*.  Any unnecessary
    slowdown when hashing is a tangible advantage for a brute-force attacker.
 
    Args:
        time_cost:
            Defines the amount of computation realized and therefore the
            execution time, given in number of iterations.
 
        memory_cost: Defines the memory usage, given in kibibytes_.
 
        parallelism:
            Defines the number of parallel threads (*changes* the resulting
            hash value).
 
        hash_len: Length of the hash in bytes.
 
        salt_len: Length of random salt to be generated for each password.
 
        encoding:
            The Argon2 C library expects bytes.  So if :meth:`hash` or
            :meth:`verify` are passed a ``str``, it will be encoded using this
            encoding.
 
        type:
            Argon2 type to use.  Only change for interoperability with legacy
            systems.
 
    .. versionadded:: 16.0.0
    .. versionchanged:: 18.2.0
       Switch from Argon2i to Argon2id based on the recommendation by the
       current RFC draft. See also :doc:`parameters`.
    .. versionchanged:: 18.2.0
       Changed default *memory_cost* to 100 MiB and default *parallelism* to 8.
    .. versionchanged:: 18.2.0 ``verify`` now will determine the type of hash.
    .. versionchanged:: 18.3.0 The Argon2 type is configurable now.
    .. versionadded:: 21.2.0 :meth:`from_parameters`
    .. versionchanged:: 21.2.0
       Changed defaults to :data:`argon2.profiles.RFC_9106_LOW_MEMORY`.
 
    .. _salt: https://en.wikipedia.org/wiki/Salt_(cryptography)
    .. _kibibytes: https://en.wikipedia.org/wiki/Binary_prefix#kibi
    Ú _parametersrrÚstrzutf-8c
óì—t|tf|tf|tf|tf|tf|tf|tf¬«}|r t    |«‚t |d|||||¬«}    t |    «|    |_||_y)N)Ú    time_costÚ memory_costÚ parallelismÚhash_lenÚsalt_lenrÚtypeé)r#Úversionr"r!rrr )    rÚintrr Ú    TypeErrorrr
rr)
Úselfrrr r!r"rr#ÚeÚparamss
          rÚ__init__zPasswordHasher.__init__^s‹€ô Ø ¤#Ð&Ø$¤cÐ*Ø$¤cÐ*ؤ_ؤ_ؤ_Øœô
ˆñ ܘA“,Ð äØØØØØØ#Ø#ô
ˆô    % VÔ,ð"ˆÔØ ˆ rcó–—||j|j|j|j|j|j
¬«S)z¼
        Construct a `PasswordHasher` from *params*.
 
        Returns:
            A `PasswordHasher` instance with the parameters from *params*.
 
        .. versionadded:: 21.2.0
        ©rrr r!r"r#r-)Úclsr*s  rÚfrom_parameterszPasswordHasher.from_parameters„sA€ñØ×&Ñ&Ø×*Ñ*Ø×*Ñ*Ø—_‘_Ø—_‘_Ø—‘ô 
ð    
rcó.—|jjS©N)rr©r(s rrzPasswordHasher.time_cost˜s€à×Ñ×)Ñ)Ð)rcó.—|jjSr1)rrr2s rrzPasswordHasher.memory_costœó€à×Ñ×+Ñ+Ð+rcó.—|jjSr1)rr r2s rr zPasswordHasher.parallelism r4rcó.—|jjSr1)rr!r2s rr!zPasswordHasher.hash_len¤ó€à×Ñ×(Ñ(Ð(rcó.—|jjSr1)rr"r2s rr"zPasswordHasher.salt_len¨r7rcó.—|jjSr1)rr#r2s rr#zPasswordHasher.type¬s€à×Ñ×$Ñ$Ð$rN)Úsaltc    ó—tt||j«|xstj|j
«|j |j|j|j|j¬«jd«S)a
        Hash *password* and return an encoded hash.
 
        Args:
            password: Password to hash.
 
            salt:
                If None, a random salt is securely created.
 
                .. danger::
 
                    You should **not** pass a salt unless you really know what
                    you are doing.
 
        Raises:
            argon2.exceptions.HashingError: If hashing fails.
 
        Returns:
            Hashed *password*.
 
        .. versionadded:: 23.1.0 *salt* parameter
        )Úsecretr:rrr r!r#Úascii) r rrÚosÚurandomr"rrr r!r#Údecode)r(Úpasswordr:s   rÚhashzPasswordHasher.hash°sf€ô.Ü  ¨4¯=©=Ó9ØÒ2œŸ™ D§M¡MÓ2Ø—n‘nØ×(Ñ(Ø×(Ñ(Ø—]‘]Ø—‘ô
÷ ‰&‹/ð    r)s    $argon2i$s    $argon2d$s    $argon2idzClassVar[dict[bytes, Type]]Ú_header_to_typecóª—t|d«}    |j|dd}t    |t||j
«|«S#t$rtd‚wxYw)ak
        Verify that *password* matches *hash*.
 
        .. warning::
 
            It is assumed that the caller is in full control of the hash.  No
            other parsing than the determination of the hash type is done by
            *argon2-cffi*.
 
        Args:
            hash: An encoded hash as returned from :meth:`PasswordHasher.hash`.
 
            password: The password to verify.
 
        Raises:
            argon2.exceptions.VerifyMismatchError:
                If verification fails because *hash* is not valid for
                *password*.
 
            argon2.exceptions.VerificationError:
                If verification fails for other reasons.
 
            argon2.exceptions.InvalidHashError:
                If *hash* is so clearly invalid, that it couldn't be passed to
                Argon2.
 
        Returns:
            ``True`` on success, otherwise an exception is raised.
 
        .. versionchanged:: 16.1.0
            Raise :exc:`~argon2.exceptions.VerifyMismatchError` on mismatches
            instead of its more generic superclass.
        .. versionadded:: 18.2.0 Hash type agility.
        r=Né    )rrCÚ LookupErrorr rr)r(rBrAÚ    hash_types    rÚverifyzPasswordHasher.verify×sf€ôJ˜T 7Ó+ˆð    -Ø×,Ñ,¨T°"°1¨XÑ6ˆIôØ ”- ¨$¯-©-Ó8¸)ó
ð    
øôò    -Ü"¨Ð ,ð    -ús ŽAÁAcót—t|t«r|jd«}|jt    |«k7S)a
        Check whether *hash* was created using the instance's parameters.
 
        Whenever your Argon2 parameters -- or *argon2-cffi*'s defaults! --
        change, you should rehash your passwords at the next opportunity.  The
        common approach is to do that whenever a user logs in, since that
        should be the only time when you have access to the cleartext
        password.
 
        Therefore it's best practice to check -- and if necessary rehash --
        passwords after each successful authentication.
 
        Args:
            hash: An encoded Argon2 password hash.
 
        Returns:
            Whether *hash* was created using the instance's parameters.
 
        .. versionadded:: 18.2.0
        .. versionchanged:: 24.1.0 Accepts bytes for *hash*.
        r=)rrr@rr    )r(rBs  rÚcheck_needs_rehashz!PasswordHasher.check_needs_rehashs3€ô, dœEÔ "Ø—;‘;˜wÓ'ˆDà×ÑÔ#5°dÓ#;Ñ;Ð;r)rr&rr&r r&r!r&r"r&rrr#r )r*rÚreturnr)rKr&)rKr )rAú str | bytesr:z bytes | NonerKr)rBrLrArLrKz Literal[True])rBrLrKÚbool)Ú__name__Ú
__module__Ú __qualname__Ú__doc__Ú    __slots__Ú__annotations__ÚDEFAULT_TIME_COSTÚDEFAULT_MEMORY_COSTÚDEFAULT_PARALLELISMÚDEFAULT_HASH_LENGTHÚDEFAULT_RANDOM_SALT_LENGTHr ÚIDr+Ú classmethodr/Úpropertyrrr r!r"r#rBÚIÚDrCrHrJ©rrrr&sf…ñ0ðd 
Ð+€IàÓØƒMð+Ø.Ø.Ø+Ø2ØØ—W‘Wð$!àð$!ðð$!ðð    $!ð
ð $!ð ð $!ðð$!ðó$!ðLò
óð
ð&ò*óð*ðò,óð,ðò,óð,ðò)óð)ðò)óð)ðò%óð%ðCGõðD—f‘fØ—f‘fØ—g‘gñ4€OÐ0óð -
Øð-
Ø+6ð-
à    ó-
ô^<rr)rz bytes | strrrrKr) Ú
__future__rr>ÚtypingrrÚ_utilsrrr    r
Ú
exceptionsr Ú    low_levelr r rÚprofilesrÚdefault_paramsr"rXr!rWrrTrrUr rVrrr^rrú<module>rfsðõ#ã    ç$÷óõ )ß7Ñ7Ý,ñ(Ó)€à+×4Ñ4ÐØ$×-Ñ-ÐØ"×,Ñ,ÐØ$×0Ñ0ÐØ$×0Ñ0Ðó÷y<òy<r