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

Method get_algorithm_impls

Lib/urllib/request.py:1180–1194  ·  view source on GitHub ↗
(self, algorithm)

Source from the content-addressed store, hash-verified

1178 return base
1179
1180 def get_algorithm_impls(self, algorithm):
1181 # algorithm names taken from RFC 7616 Section 6.1
1182 # lambdas assume digest modules are imported at the top level
1183 if algorithm == 'MD5':
1184 H = lambda x: hashlib.md5(x.encode("ascii")).hexdigest()
1185 elif algorithm == 'SHA': # non-standard, retained for compatibility.
1186 H = lambda x: hashlib.sha1(x.encode("ascii")).hexdigest()
1187 elif algorithm == 'SHA-256':
1188 H = lambda x: hashlib.sha256(x.encode("ascii")).hexdigest()
1189 # XXX MD5-sess
1190 else:
1191 raise ValueError("Unsupported digest authentication "
1192 "algorithm %r" % algorithm)
1193 KD = lambda s, d: H("%s:%s" % (s, d))
1194 return H, KD
1195
1196 def get_entity_digest(self, data, chal):
1197 # XXX not implemented yet

Callers 5

get_authorizationMethod · 0.95
test_md5_algorithmMethod · 0.80
test_sha_algorithmMethod · 0.80
test_sha256_algorithmMethod · 0.80

Calls 3

hexdigestMethod · 0.80
HClass · 0.50
encodeMethod · 0.45

Tested by 4

test_md5_algorithmMethod · 0.64
test_sha_algorithmMethod · 0.64
test_sha256_algorithmMethod · 0.64