MCPcopy
hub / github.com/authlib/authlib / create_half_hash

Function create_half_hash

authlib/oidc/core/util.py:7–18  ·  view source on GitHub ↗
(s, alg)

Source from the content-addressed store, hash-verified

5
6
7def create_half_hash(s, alg):
8 if alg == "EdDSA":
9 hash_alg = hashlib.sha512
10 else:
11 hash_type = f"sha{alg[2:]}"
12 hash_alg = getattr(hashlib, hash_type, None)
13 if not hash_alg:
14 return None
15
16 data_digest = hash_alg(to_bytes(s)).digest()
17 slice_index = int(len(data_digest) / 2)
18 return urlsafe_b64encode(data_digest[:slice_index])

Callers 13

test_openid_authorizeFunction · 0.90
test_parse_id_tokenFunction · 0.90
test_parse_id_tokenFunction · 0.90
test_openid_authorizeFunction · 0.90
_verify_hashFunction · 0.85
encode_id_tokenMethod · 0.85

Calls 2

to_bytesFunction · 0.90
urlsafe_b64encodeFunction · 0.90

Tested by 9

test_openid_authorizeFunction · 0.72
test_parse_id_tokenFunction · 0.72
test_parse_id_tokenFunction · 0.72
test_openid_authorizeFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…