• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# coding: utf-8
2from __future__ import unicode_literals, division, absolute_import, print_function
3
4
5def fill_width(bytes_, width):
6    """
7    Ensure a byte string representing a positive integer is a specific width
8    (in bytes)
9
10    :param bytes_:
11        The integer byte string
12
13    :param width:
14        The desired width as an integer
15
16    :return:
17        A byte string of the width specified
18    """
19
20    while len(bytes_) < width:
21        bytes_ = b'\x00' + bytes_
22    return bytes_
23