MCPcopy Create free account
hub / github.com/mongodb/mongo-python-driver / _password_digest

Function _password_digest

pymongo/synchronous/auth.py:154–166  ·  view source on GitHub ↗

Get a password digest to use for authentication.

(username: str, password: str)

Source from the content-addressed store, hash-verified

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

Callers 2

_authenticate_scramFunction · 0.70
_auth_keyFunction · 0.70

Calls 2

encodeMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected