@@ -112,7 +112,7 @@ def decorated(*args: t.Any, **kwargs: t.Any) -> t.Any:
112
112
return decorated
113
113
114
114
115
- def compare_type5 (
115
+ def compare_cisco_type5 (
116
116
unencrypted_password : str , encrypted_password : str , return_original : bool = False
117
117
) -> t .Union [str , bool ]:
118
118
"""Given an encrypted and unencrypted password of Cisco Type 5 password, compare if they are a match.
@@ -126,22 +126,22 @@ def compare_type5(
126
126
Whether or not the password is as compared to.
127
127
128
128
Examples:
129
- >>> from netutils.password import compare_type5
130
- >>> compare_type5 ("cisco","$1$nTc1$Z28sUTcWfXlvVe2x.3XAa.")
129
+ >>> from netutils.password import compare_cisco_type5
130
+ >>> compare_cisco_type5 ("cisco","$1$nTc1$Z28sUTcWfXlvVe2x.3XAa.")
131
131
True
132
- >>> compare_type5 ("not_cisco","$1$nTc1$Z28sUTcWfXlvVe2x.3XAa.")
132
+ >>> compare_cisco_type5 ("not_cisco","$1$nTc1$Z28sUTcWfXlvVe2x.3XAa.")
133
133
False
134
134
>>>
135
135
"""
136
136
salt = get_hash_salt (encrypted_password )
137
- if encrypt_type5 (unencrypted_password , salt ) == encrypted_password :
137
+ if encrypt_cisco_type5 (unencrypted_password , salt ) == encrypted_password :
138
138
if return_original is True :
139
139
return encrypted_password
140
140
return True
141
141
return False
142
142
143
143
144
- def compare_type7 (
144
+ def compare_cisco_type7 (
145
145
unencrypted_password : str , encrypted_password : str , return_original : bool = False
146
146
) -> t .Union [str , bool ]:
147
147
"""Given an encrypted and unencrypted password of Cisco Type 7 password, compare if they are a match.
@@ -155,24 +155,24 @@ def compare_type7(
155
155
Whether or not the password is as compared to.
156
156
157
157
Examples:
158
- >>> from netutils.password import compare_type7
159
- >>> compare_type7 ("cisco","121A0C041104")
158
+ >>> from netutils.password import compare_cisco_type7
159
+ >>> compare_cisco_type7 ("cisco","121A0C041104")
160
160
True
161
- >>> compare_type7 ("not_cisco","121A0C041104")
161
+ >>> compare_cisco_type7 ("not_cisco","121A0C041104")
162
162
False
163
163
>>>
164
164
"""
165
- if decrypt_type7 (encrypted_password ) == unencrypted_password :
165
+ if decrypt_cisco_type7 (encrypted_password ) == unencrypted_password :
166
166
if return_original is True :
167
167
return encrypted_password
168
168
return True
169
169
return False
170
170
171
171
172
- def compare_type9 (
172
+ def compare_cisco_type9 (
173
173
unencrypted_password : str , encrypted_password : str , return_original : bool = False
174
174
) -> t .Union [str , bool ]:
175
- """Given an encrypted and unencrypted password of Cisco Type 7 password, compare if they are a match.
175
+ """Given an encrypted and unencrypted password of Cisco Type 9 password, compare if they are a match.
176
176
177
177
Args:
178
178
unencrypted_password: A password that has not been encrypted, and will be compared against.
@@ -183,22 +183,22 @@ def compare_type9(
183
183
Whether or not the password is as compared to.
184
184
185
185
Examples:
186
- >>> from netutils.password import compare_type9
187
- >>> compare_type9 ("cisco","$9$588|P!iWqEx=Wf$nadLmT9snc6V9QAeUuATSOoCAZMQIHqixJfZpQj5EU2")
186
+ >>> from netutils.password import compare_cisco_type9
187
+ >>> compare_cisco_type9 ("cisco","$9$588|P!iWqEx=Wf$nadLmT9snc6V9QAeUuATSOoCAZMQIHqixJfZpQj5EU2")
188
188
True
189
- >>> compare_type9 ("not_cisco","$9$588|P!iWqEx=Wf$nadLmT9snc6V9QAeUuATSOoCAZMQIHqixJfZpQj5EU2")
189
+ >>> compare_cisco_type9 ("not_cisco","$9$588|P!iWqEx=Wf$nadLmT9snc6V9QAeUuATSOoCAZMQIHqixJfZpQj5EU2")
190
190
False
191
191
>>>
192
192
"""
193
193
salt = get_hash_salt (encrypted_password )
194
- if encrypt_type9 (unencrypted_password , salt ) == encrypted_password :
194
+ if encrypt_cisco_type9 (unencrypted_password , salt ) == encrypted_password :
195
195
if return_original is True :
196
196
return encrypted_password
197
197
return True
198
198
return False
199
199
200
200
201
- def decrypt_type7 (encrypted_password : str ) -> str :
201
+ def decrypt_cisco_type7 (encrypted_password : str ) -> str :
202
202
"""Given an unencrypted password of Cisco Type 7 password decrypt it.
203
203
204
204
Args:
@@ -208,8 +208,8 @@ def decrypt_type7(encrypted_password: str) -> str:
208
208
The unencrypted_password password.
209
209
210
210
Examples:
211
- >>> from netutils.password import decrypt_type7
212
- >>> decrypt_type7 ("121A0C041104")
211
+ >>> from netutils.password import decrypt_cisco_type7
212
+ >>> decrypt_cisco_type7 ("121A0C041104")
213
213
'cisco'
214
214
>>>
215
215
"""
@@ -229,7 +229,7 @@ def decrypt_type7(encrypted_password: str) -> str:
229
229
230
230
231
231
@_fail_on_mac
232
- def encrypt_type5 (unencrypted_password : str , salt : t .Optional [str ] = None , salt_len : int = 4 ) -> str :
232
+ def encrypt_cisco_type5 (unencrypted_password : str , salt : t .Optional [str ] = None , salt_len : int = 4 ) -> str :
233
233
"""Given an unencrypted password of Cisco Type 5 password, encrypt it.
234
234
235
235
Args:
@@ -241,8 +241,8 @@ def encrypt_type5(unencrypted_password: str, salt: t.Optional[str] = None, salt_
241
241
The encrypted password.
242
242
243
243
Examples:
244
- >>> from netutils.password import encrypt_type5
245
- >>> encrypt_type5 ("cisco") # doctest: +SKIP
244
+ >>> from netutils.password import encrypt_cisco_type5
245
+ >>> encrypt_cisco_type5 ("cisco") # doctest: +SKIP
246
246
'$1$MHkb$v2MFmDkQX66TTxLkFF50K/'
247
247
>>>
248
248
"""
@@ -253,7 +253,7 @@ def encrypt_type5(unencrypted_password: str, salt: t.Optional[str] = None, salt_
253
253
return crypt .crypt (unencrypted_password , f"$1${ salt } $" )
254
254
255
255
256
- def encrypt_type7 (unencrypted_password : str , salt : t .Optional [int ] = None ) -> str :
256
+ def encrypt_cisco_type7 (unencrypted_password : str , salt : t .Optional [int ] = None ) -> str :
257
257
"""Given an unencrypted password of Cisco Type 7 password, encypt it.
258
258
259
259
Args:
@@ -264,8 +264,8 @@ def encrypt_type7(unencrypted_password: str, salt: t.Optional[int] = None) -> st
264
264
The encrypted password.
265
265
266
266
Examples:
267
- >>> from netutils.password import encrypt_type7
268
- >>> encrypt_type7 ("cisco", 11)
267
+ >>> from netutils.password import encrypt_cisco_type7
268
+ >>> encrypt_cisco_type7 ("cisco", 11)
269
269
'110A1016141D'
270
270
>>>
271
271
"""
@@ -290,7 +290,7 @@ def encrypt_type7(unencrypted_password: str, salt: t.Optional[int] = None) -> st
290
290
return encrypted_password
291
291
292
292
293
- def encrypt_type9 (unencrypted_password : str , salt : t .Optional [str ] = None ) -> str :
293
+ def encrypt_cisco_type9 (unencrypted_password : str , salt : t .Optional [str ] = None ) -> str :
294
294
"""Given an unencrypted password of Cisco Type 9 password, encrypt it.
295
295
296
296
Note: This uses the built-in Python `scrypt` function to generate the password
@@ -306,8 +306,8 @@ def encrypt_type9(unencrypted_password: str, salt: t.Optional[str] = None) -> st
306
306
The encrypted password.
307
307
308
308
Examples:
309
- >>> from netutils.password import encrypt_type9
310
- >>> encrypt_type9 ("123456", "cvWdfQlRRDKq/U")
309
+ >>> from netutils.password import encrypt_cisco_type9
310
+ >>> encrypt_cisco_type9 ("123456", "cvWdfQlRRDKq/U")
311
311
'$9$cvWdfQlRRDKq/U$VFTPha5VHTCbSgSUAo.nPoh50ZiXOw1zmljEjXkaq1g'
312
312
313
313
Raises:
@@ -364,7 +364,7 @@ def get_hash_salt(encrypted_password: str) -> str:
364
364
return split_password [2 ]
365
365
366
366
367
- def decrypt_juniper (encrypted_password : str ) -> str :
367
+ def decrypt_juniper_type9 (encrypted_password : str ) -> str :
368
368
"""Given an encrypted Junos $9$ type password, decrypt it.
369
369
370
370
Args:
@@ -374,8 +374,8 @@ def decrypt_juniper(encrypted_password: str) -> str:
374
374
The unencrypted_password password.
375
375
376
376
Examples:
377
- >>> from netutils.password import decrypt_juniper
378
- >>> decrypt_juniper ("$9$7YdwgGDkTz6oJz69A1INdb")
377
+ >>> from netutils.password import decrypt_juniper_type9
378
+ >>> decrypt_juniper_type9 ("$9$7YdwgGDkTz6oJz69A1INdb")
379
379
'juniper'
380
380
>>>
381
381
"""
@@ -409,7 +409,7 @@ def decrypt_juniper(encrypted_password: str) -> str:
409
409
return decrypted_password
410
410
411
411
412
- def encrypt_juniper (unencrypted_password : str , salt : t .Optional [int ] = None ) -> str :
412
+ def encrypt_juniper_type9 (unencrypted_password : str , salt : t .Optional [int ] = None ) -> str :
413
413
"""Given an unencrypted password, encrypt to Juniper $9$ type password.
414
414
415
415
Args:
@@ -420,8 +420,8 @@ def encrypt_juniper(unencrypted_password: str, salt: t.Optional[int] = None) ->
420
420
The encrypted password.
421
421
422
422
Examples:
423
- >>> from netutils.password import encrypt_juniper
424
- >>> encrypt_juniper ("juniper", 35) # doctest: +SKIP
423
+ >>> from netutils.password import encrypt_juniper_type9
424
+ >>> encrypt_juniper_type9 ("juniper", 35) # doctest: +SKIP
425
425
'$9$7YdwgGDkTz6oJz69A1INdb'
426
426
>>>
427
427
"""
@@ -454,3 +454,11 @@ def encrypt_juniper(unencrypted_password: str, salt: t.Optional[int] = None) ->
454
454
encrypted_password += new_character
455
455
456
456
return encrypted_password
457
+
458
+
459
+ # Provide until transition to 2.0
460
+ compare_type5 = compare_cisco_type5
461
+ compare_type7 = compare_cisco_type7
462
+ decrypt_type7 = decrypt_cisco_type7
463
+ encrypt_type5 = encrypt_cisco_type5
464
+ encrypt_type7 = encrypt_cisco_type7
0 commit comments