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

Function _password_digest

pymongo/asynchronous/auth.py:157–169  ·  view source on GitHub ↗

Get a password digest to use for authentication.

(username: str, password: str)

Source from the content-addressed store, hash-verified

155
156
157def _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
172def _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