MCPcopy Create free account
hub / github.com/python/cpython / _CRAM_MD5_AUTH

Method _CRAM_MD5_AUTH

Lib/imaplib.py:720–733  ·  view source on GitHub ↗

Authobject to use with CRAM-MD5 authentication.

(self, challenge)

Source from the content-addressed store, hash-verified

718
719
720 def _CRAM_MD5_AUTH(self, challenge):
721 """ Authobject to use with CRAM-MD5 authentication. """
722 import hmac
723
724 if isinstance(self.password, str):
725 password = self.password.encode('utf-8')
726 else:
727 password = self.password
728
729 try:
730 authcode = hmac.HMAC(password, challenge, 'md5')
731 except ValueError: # HMAC-MD5 is not available
732 raise self.error("CRAM-MD5 authentication is not supported")
733 return f"{self.user} {authcode.hexdigest()}"
734
735
736 def logout(self):

Callers

nothing calls this directly

Calls 4

hexdigestMethod · 0.95
encodeMethod · 0.45
HMACMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected