|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric6.Utilities.crypto.py3PBKDF2</title> |
|
4 <meta charset="UTF-8"> |
|
5 <style> |
|
6 body { |
|
7 background: #EDECE6; |
|
8 margin: 0em 1em 10em 1em; |
|
9 color: black; |
|
10 } |
|
11 |
|
12 h1 { color: white; background: #85774A; } |
|
13 h2 { color: white; background: #85774A; } |
|
14 h3 { color: white; background: #9D936E; } |
|
15 h4 { color: white; background: #9D936E; } |
|
16 |
|
17 a { color: #BA6D36; } |
|
18 |
|
19 </style> |
|
20 </head> |
|
21 <body><a NAME="top" ID="top"></a> |
|
22 <h1>eric6.Utilities.crypto.py3PBKDF2</h1> |
|
23 <p> |
|
24 Module implementing PBKDF2 functions. |
|
25 </p> |
|
26 <h3>Global Attributes</h3> |
|
27 <table> |
|
28 <tr><td>Delimiter</td></tr><tr><td>Hashes</td></tr> |
|
29 </table> |
|
30 <h3>Classes</h3> |
|
31 <table> |
|
32 <tr><td>None</td></tr> |
|
33 </table> |
|
34 <h3>Functions</h3> |
|
35 <table> |
|
36 <tr> |
|
37 <td><a href="#hashPassword">hashPassword</a></td> |
|
38 <td>Module function to hash a password according to the PBKDF2 specification.</td> |
|
39 </tr><tr> |
|
40 <td><a href="#hashPasswordTuple">hashPasswordTuple</a></td> |
|
41 <td>Module function to hash a password according to the PBKDF2 specification.</td> |
|
42 </tr><tr> |
|
43 <td><a href="#pbkdf2">pbkdf2</a></td> |
|
44 <td>Module function to hash a password according to the PBKDF2 specification.</td> |
|
45 </tr><tr> |
|
46 <td><a href="#rehashPassword">rehashPassword</a></td> |
|
47 <td>Module function to recreate a password hash given the hash parameters.</td> |
|
48 </tr><tr> |
|
49 <td><a href="#verifyPassword">verifyPassword</a></td> |
|
50 <td>Module function to verify a password against a hash encoded password.</td> |
|
51 </tr> |
|
52 </table> |
|
53 <hr /><hr /> |
|
54 <a NAME="hashPassword" ID="hashPassword"></a> |
|
55 <h2>hashPassword</h2> |
|
56 <b>hashPassword</b>(<i>password, digestMod=hashlib.sha512, iterations=10000, saltSize=32</i>) |
|
57 <p> |
|
58 Module function to hash a password according to the PBKDF2 specification. |
|
59 </p><dl> |
|
60 <dt><i>password</i></dt> |
|
61 <dd> |
|
62 clear text password (string) |
|
63 </dd><dt><i>digestMod</i></dt> |
|
64 <dd> |
|
65 hash function |
|
66 </dd><dt><i>iterations</i></dt> |
|
67 <dd> |
|
68 number of times hash function should be applied (integer) |
|
69 </dd><dt><i>saltSize</i></dt> |
|
70 <dd> |
|
71 size of the salt (integer) |
|
72 </dd> |
|
73 </dl><dl> |
|
74 <dt>Returns:</dt> |
|
75 <dd> |
|
76 hashed password entry according to PBKDF2 specification (string) |
|
77 </dd> |
|
78 </dl> |
|
79 <div align="right"><a href="#top">Up</a></div> |
|
80 <hr /><hr /> |
|
81 <a NAME="hashPasswordTuple" ID="hashPasswordTuple"></a> |
|
82 <h2>hashPasswordTuple</h2> |
|
83 <b>hashPasswordTuple</b>(<i>password, digestMod=hashlib.sha512, iterations=10000, saltSize=32</i>) |
|
84 <p> |
|
85 Module function to hash a password according to the PBKDF2 specification. |
|
86 </p><dl> |
|
87 <dt><i>password</i></dt> |
|
88 <dd> |
|
89 clear text password (string) |
|
90 </dd><dt><i>digestMod</i></dt> |
|
91 <dd> |
|
92 hash function |
|
93 </dd><dt><i>iterations</i></dt> |
|
94 <dd> |
|
95 number of times hash function should be applied (integer) |
|
96 </dd><dt><i>saltSize</i></dt> |
|
97 <dd> |
|
98 size of the salt (integer) |
|
99 </dd> |
|
100 </dl><dl> |
|
101 <dt>Returns:</dt> |
|
102 <dd> |
|
103 tuple of digestname (string), number of iterations (integer), |
|
104 salt (bytes) and hashed password (bytes) |
|
105 </dd> |
|
106 </dl> |
|
107 <div align="right"><a href="#top">Up</a></div> |
|
108 <hr /><hr /> |
|
109 <a NAME="pbkdf2" ID="pbkdf2"></a> |
|
110 <h2>pbkdf2</h2> |
|
111 <b>pbkdf2</b>(<i>password, salt, iterations, digestMod</i>) |
|
112 <p> |
|
113 Module function to hash a password according to the PBKDF2 specification. |
|
114 </p><dl> |
|
115 <dt><i>password</i></dt> |
|
116 <dd> |
|
117 clear text password (bytes) |
|
118 </dd><dt><i>salt</i></dt> |
|
119 <dd> |
|
120 salt value (bytes) |
|
121 </dd><dt><i>iterations</i></dt> |
|
122 <dd> |
|
123 number of times hash function should be applied (integer) |
|
124 </dd><dt><i>digestMod</i></dt> |
|
125 <dd> |
|
126 hash function |
|
127 </dd> |
|
128 </dl><dl> |
|
129 <dt>Returns:</dt> |
|
130 <dd> |
|
131 hashed password (bytes) |
|
132 </dd> |
|
133 </dl> |
|
134 <div align="right"><a href="#top">Up</a></div> |
|
135 <hr /><hr /> |
|
136 <a NAME="rehashPassword" ID="rehashPassword"></a> |
|
137 <h2>rehashPassword</h2> |
|
138 <b>rehashPassword</b>(<i>password, hashParameters</i>) |
|
139 <p> |
|
140 Module function to recreate a password hash given the hash parameters. |
|
141 </p><dl> |
|
142 <dt><i>password</i></dt> |
|
143 <dd> |
|
144 clear text password (string) |
|
145 </dd><dt><i>hashParameters</i></dt> |
|
146 <dd> |
|
147 hash parameters in the form |
|
148 'digestmod$iterations$salt' (string) |
|
149 </dd> |
|
150 </dl><dl> |
|
151 <dt>Returns:</dt> |
|
152 <dd> |
|
153 hashed password (bytes) |
|
154 </dd> |
|
155 </dl><dl> |
|
156 <dt>Raises <b>ValueError</b>:</dt> |
|
157 <dd> |
|
158 the hash parameters string is not of the expected |
|
159 format or the digest is not one of the known ones |
|
160 </dd> |
|
161 </dl> |
|
162 <div align="right"><a href="#top">Up</a></div> |
|
163 <hr /><hr /> |
|
164 <a NAME="verifyPassword" ID="verifyPassword"></a> |
|
165 <h2>verifyPassword</h2> |
|
166 <b>verifyPassword</b>(<i>password, hash</i>) |
|
167 <p> |
|
168 Module function to verify a password against a hash encoded password. |
|
169 </p><dl> |
|
170 <dt><i>password</i></dt> |
|
171 <dd> |
|
172 clear text password (string) |
|
173 </dd><dt><i>hash</i></dt> |
|
174 <dd> |
|
175 hash encoded password in the form |
|
176 'digestmod$iterations$salt$hashed_password' as produced by the |
|
177 hashPassword function (string) |
|
178 </dd> |
|
179 </dl><dl> |
|
180 <dt>Returns:</dt> |
|
181 <dd> |
|
182 flag indicating a successfull verification (boolean) |
|
183 </dd> |
|
184 </dl><dl> |
|
185 <dt>Raises <b>ValueError</b>:</dt> |
|
186 <dd> |
|
187 the hash is not of the expected format or the |
|
188 digest is not one of the known ones |
|
189 </dd> |
|
190 </dl> |
|
191 <div align="right"><a href="#top">Up</a></div> |
|
192 <hr /> |
|
193 </body></html> |