Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/741.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed the logic error where `salt=0` was ignored in `encrypt_cisco_type7`
2 changes: 1 addition & 1 deletion netutils/password.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def encrypt_cisco_type7(unencrypted_password: str, salt: t.Optional[int] = None)
if len(unencrypted_password) > ENCRYPT_TYPE7_LENGTH:
raise ValueError("Password must not exceed 25 characters.")

if not salt:
if salt is None:
salt = random.randint(0, 15) # noqa: S311
# Start building the encrypted password - pre-pend the 2 decimal digit offset.
encrypted_password = format(salt, "02d")
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/test_password.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@
"sent": {"unencrypted_password": "cisco", "salt": 10},
"received": "104D000A0618",
},
{
"sent": {"unencrypted_password": "cisco", "salt": 0},
"received": "00071A150754",
},
]

ENCRYPT_CISCO_TYPE9 = [
Expand Down