MCPcopy Index your code
hub / github.com/python/cpython / auth_cram_md5

Method auth_cram_md5

Lib/smtplib.py:671–681  ·  view source on GitHub ↗

Authobject to use with CRAM-MD5 authentication. Requires self.user and self.password to be set.

(self, challenge=None)

Source from the content-addressed store, hash-verified

669 raise SMTPAuthenticationError(code, resp)
670
671 def auth_cram_md5(self, challenge=None):
672 """ Authobject to use with CRAM-MD5 authentication. Requires self.user
673 and self.password to be set."""
674 # CRAM-MD5 does not support initial-response.
675 if challenge is None:
676 return None
677 if not _have_cram_md5_support:
678 raise SMTPException("CRAM-MD5 is not supported")
679 password = self.password.encode('ascii')
680 authcode = hmac.HMAC(password, challenge, 'md5')
681 return f"{self.user} {authcode.hexdigest()}"
682
683 def auth_plain(self, challenge=None):
684 """ Authobject to use with PLAIN authentication. Requires self.user and

Callers

nothing calls this directly

Calls 4

hexdigestMethod · 0.95
SMTPExceptionClass · 0.85
encodeMethod · 0.45
HMACMethod · 0.45

Tested by

no test coverage detected