MCPcopy Index your code
hub / github.com/dbcli/mycli / _remove_pad

Function _remove_pad

mycli/config.py:238–254  ·  view source on GitHub ↗

Remove the pad from the *line*.

(line: bytes)

Source from the content-addressed store, hash-verified

236
237
238def _remove_pad(line: bytes) -> bytes | Literal[False]:
239 """Remove the pad from the *line*."""
240 try:
241 # Determine pad length.
242 pad_length = ord(line[-1:])
243 except TypeError:
244 # ord() was unable to get the value of the byte.
245 logger.warning("Unable to remove pad.")
246 return False
247
248 if pad_length > len(line) or len(set(line[-pad_length:])) != 1:
249 # Pad length should be less than or equal to the length of the
250 # plaintext. The pad should have a single unique byte.
251 logger.warning("Invalid pad found in login path file.")
252 return False
253
254 return line[:-pad_length]

Calls 1

warningMethod · 0.45

Tested by 1