<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Released into public domain.

"""
:module: pyoauth.types.number
:synopsis: Number routines.

Functions:
----------
.. autofunction:: bytes_to_long
.. autofunction:: bytes_to_long_original
.. autofunction:: long_to_bytes
.. autofunction:: long_to_bytes_original
.. autofunction:: mpi_to_long
.. autofunction:: long_to_mpi
.. autofunction:: pow_mod
.. autofunction:: inverse_mod
"""


import struct

from pyoauth.types.bytearray import \
    bytearray_concat, \
    bytearray_create_zeros, \
    bytes_to_bytearray, \
    bytearray_to_bytes, \
    long_to_bytearray, \
    bytearray_to_long


# Improved conversion functions contributed by <NAME>, after
# careful benchmarking

def long_to_bytes(num, blocksize=0):
    """
    Convert a long integer to a byte string::<commit_msg>Adds note about source for long_to_bytes and bytes_to_long<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Released into public domain.

"""
:module: pyoauth.types.number
:synopsis: Number routines.

Functions:
----------
.. autofunction:: bytes_to_long
.. autofunction:: bytes_to_long_original
.. autofunction:: long_to_bytes
.. autofunction:: long_to_bytes_original
.. autofunction:: mpi_to_long
.. autofunction:: long_to_mpi
.. autofunction:: pow_mod
.. autofunction:: inverse_mod
"""


import struct

from pyoauth.types.bytearray import \
    bytearray_concat, \
    bytearray_create_zeros, \
    bytes_to_bytearray, \
    bytearray_to_bytes, \
    long_to_bytearray, \
    bytearray_to_long

# Taken from PyCrypto "as is".
# Improved conversion functions contributed by <NAME>, after
# careful benchmarking

def long_to_bytes(num, blocksize=0):
    """
    Convert a long integer to a byte string::
{'fraction_non_alphanumeric': 0.12038614423622941, 'fraction_numerical': 0.002271436683702442, 'mean_word_length': 3.949438202247191, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4476675', 'n_tokens_mistral': 591, 'n_tokens_neox': 579, 'n_words': 133}