diff options
Diffstat (limited to 'rsa/transform.py')
-rw-r--r-- | rsa/transform.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/rsa/transform.py b/rsa/transform.py index 7be272c..092b1ca 100644 --- a/rsa/transform.py +++ b/rsa/transform.py @@ -14,10 +14,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Data transformation functions. +'''Data transformation functions. From bytes to a number, number to bytes, etc. -""" +''' from __future__ import absolute_import @@ -37,7 +37,7 @@ from rsa._compat import is_integer, b, byte, get_word_alignment, ZERO_BYTE, EMPT def bytes2int(raw_bytes): - r"""Converts a list of bytes or an 8-bit string to an integer. + r'''Converts a list of bytes or an 8-bit string to an integer. When using unicode strings, encode it to some encoding like UTF8 first. @@ -46,13 +46,13 @@ def bytes2int(raw_bytes): >>> bytes2int('\x80@\x0f') 8405007 - """ + ''' return int(binascii.hexlify(raw_bytes), 16) def _int2bytes(number, block_size=None): - """Converts a number to a string of bytes. + '''Converts a number to a string of bytes. Usage:: @@ -78,7 +78,7 @@ def _int2bytes(number, block_size=None): @throws OverflowError when block_size is given and the number takes up more bytes than fit into the block. - """ + ''' # Type checking if not is_integer(number): raise TypeError("You must pass an integer for 'number', not %s" % @@ -116,7 +116,7 @@ def _int2bytes(number, block_size=None): def bytes_leading(raw_bytes, needle=ZERO_BYTE): - """ + ''' Finds the number of prefixed byte occurrences in the haystack. Useful when you want to deal with padding. @@ -127,7 +127,7 @@ def bytes_leading(raw_bytes, needle=ZERO_BYTE): The byte to count. Default \000. :returns: The number of leading needle bytes. - """ + ''' leading = 0 # Indexing keeps compatibility between Python 2.x and Python 3.x _byte = needle[0] @@ -140,7 +140,7 @@ def bytes_leading(raw_bytes, needle=ZERO_BYTE): def int2bytes(number, fill_size=None, chunk_size=None, overflow=False): - """ + ''' Convert an unsigned integer to bytes (base-256 representation):: Does not preserve leading zeros if you don't specify a chunk size or @@ -172,7 +172,7 @@ def int2bytes(number, fill_size=None, chunk_size=None, overflow=False): bytes than fit into the block. This requires the ``overflow`` argument to this function to be set to ``False`` otherwise, no error will be raised. - """ + ''' if number < 0: raise ValueError("Number must be an unsigned integer: %d" % number) |