summaryrefslogtreecommitdiff
path: root/rsa/common.py
blob: b8f7aa600d7b1e75e75b583decfad7ee68c0eab7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
'''Common functionality shared by several modules.'''

import math

def bit_size(number):
    '''Returns the number of bits required to hold a specific long number.

    >>> bit_size(1023)
    10
    >>> bit_size(1024)
    10
    >>> bit_size(1025)
    11

    '''

    return int(math.ceil(math.log(number, 2)))