Get a password digest to use for authentication.
(username: str, password: str)
| 155 | |
| 156 | |
| 157 | def _password_digest(username: str, password: str) -> str: |
| 158 | """Get a password digest to use for authentication.""" |
| 159 | if not isinstance(password, str): |
| 160 | raise TypeError("password must be an instance of str") |
| 161 | if len(password) == 0: |
| 162 | raise ValueError("password can't be empty") |
| 163 | if not isinstance(username, str): |
| 164 | raise TypeError(f"username must be an instance of str, not {type(username)}") |
| 165 | |
| 166 | md5hash = hashlib.md5() # noqa: S324 |
| 167 | data = f"{username}:mongo:{password}" |
| 168 | md5hash.update(data.encode("utf-8")) |
| 169 | return md5hash.hexdigest() |
| 170 | |
| 171 | |
| 172 | def _auth_key(nonce: str, username: str, password: str) -> str: |
no test coverage detected