Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 

14 wiersze
404 B

  1. #
  2. # This file is part of pyasn1 software.
  3. #
  4. # Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>
  5. # License: https://pyasn1.readthedocs.io/en/latest/license.html
  6. #
  7. def to_bytes(value, signed=False, length=0):
  8. length = max(value.bit_length(), length)
  9. if signed and length % 8 == 0:
  10. length += 1
  11. return value.to_bytes(length // 8 + (length % 8 and 1 or 0), 'big', signed=signed)