MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / pad

Function pad

web/pgadmin/utils/crypto.py:64–78  ·  view source on GitHub ↗

Add padding to the key.

(key)

Source from the content-addressed store, hash-verified

62
63
64def pad(key):
65 """Add padding to the key."""
66
67 if isinstance(key, str):
68 key = key.encode()
69
70 # Key must be maximum 32 bytes long, so take first 32 bytes
71 key = key[:32]
72
73 # If key size is 16, 24 or 32 bytes then padding is not required
74 if len(key) in (16, 24, 32):
75 return key
76
77 # Add padding to make key 32 bytes long
78 return key.ljust(32, padding_string)

Callers 2

encryptFunction · 0.85
decryptFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected