# Path: openid/cryptutil.py
# def bytes_to_int(value):
# def fix_btwoc(value):
# def int_to_bytes(value):
# def longToBinary(value):
# def binaryToLong(s):
# def longToBase64(value):
# def base64ToLong(s):


import os.path
import random
import sys
import unittest
import warnings
import six
from openid import cryptutil
    """Test `longToBinary` and `binaryToLong` functions."""

    def test_binaryLongConvert(self):
        MAX = sys.maxsize
        with warnings.catch_warnings():
            warnings.simplefilter('ignore', category=DeprecationWarning)
            for iteration in range(500):
                n = 0
                for i in range(10):
                    n += random.randrange(MAX)

                s = cryptutil.longToBinary(n)
                assert isinstance(s, six.binary_type)
                n_prime = cryptutil.binaryToLong(s)
                assert n == n_prime, (n, n_prime)

        cases = [
            (b'\x00', 0),
            (b'\x01', 1),
            (b'\x7F', 127),
            (b'\x00\xFF', 255),
            (b'\x00\x80', 128),
            (b'\x00\x81', 129),
            (b'\x00\x80\x00', 32768),
            (b'OpenID is cool', 1611215304203901150134421257416556)
        ]

        with warnings.catch_warnings():
            warnings.simplefilter('ignore', category=DeprecationWarning)
            for s, n in cases:

# Path: openid/cryptutil.py
# def bytes_to_int(value):
# def fix_btwoc(value):
# def int_to_bytes(value):
# def longToBinary(value):
# def binaryToLong(s):
# def longToBase64(value):
# def base64ToLong(s):


# Path: openid/test/test_cryptutil.py
import os.path
import random
import sys
import unittest
import warnings
import six
from openid import cryptutil

    """Test `longToBinary` and `binaryToLong` functions."""

    def test_binaryLongConvert(self):
        MAX = sys.maxsize
        with warnings.catch_warnings():
            warnings.simplefilter('ignore', category=DeprecationWarning)
            for iteration in range(500):
                n = 0
                for i in range(10):
                    n += random.randrange(MAX)

                s = cryptutil.longToBinary(n)
                assert isinstance(s, six.binary_type)
                n_prime = cryptutil.binaryToLong(s)
                assert n == n_prime, (n, n_prime)

        cases = [
            (b'\x00', 0),
            (b'\x01', 1),
            (b'\x7F', 127),
            (b'\x00\xFF', 255),
            (b'\x00\x80', 128),
            (b'\x00\x81', 129),
            (b'\x00\x80\x00', 32768),
            (b'OpenID is cool', 1611215304203901150134421257416556)
        ]

        with warnings.catch_warnings():
            warnings.simplefilter('ignore', category=DeprecationWarning)
            for s, n in cases:

                n_prime = cryptutil.binaryToLong(s)