padding.py 533 B

12345678910111213141516171819202122232425262728
  1. from eth_utils.toolz import (
  2. curry,
  3. )
  4. # typing ignored because toolz do not provide typing info
  5. @curry # type: ignore
  6. def zpad(value: bytes, length: int) -> bytes:
  7. return value.rjust(length, b"\x00")
  8. zpad32 = zpad(length=32)
  9. @curry # type: ignore
  10. def zpad_right(value: bytes, length: int) -> bytes:
  11. return value.ljust(length, b"\x00")
  12. zpad32_right = zpad_right(length=32)
  13. @curry # type: ignore
  14. def fpad(value: bytes, length: int) -> bytes:
  15. return value.rjust(length, b"\xff")
  16. fpad32 = fpad(length=32)