summaryrefslogtreecommitdiff
path: root/rsa/common.py
diff options
context:
space:
mode:
authorYesudeep Mangalapilly <yesudeep@gmail.com>2011-08-16 14:58:32 +0530
committerYesudeep Mangalapilly <yesudeep@gmail.com>2011-08-16 14:58:32 +0530
commit5bfe5ffea25ee7aacaa48db55ed429b31714afb0 (patch)
tree133988336aaefb98b008dbaafab17a370c9b87f9 /rsa/common.py
parentd1060d36697efcd1179ffdbc7b16d3a68643b8c5 (diff)
downloadrsa-git-5bfe5ffea25ee7aacaa48db55ed429b31714afb0.tar.gz
Moves incompatible doctests to unit test modules.
Diffstat (limited to 'rsa/common.py')
-rw-r--r--rsa/common.py17
1 files changed, 2 insertions, 15 deletions
diff --git a/rsa/common.py b/rsa/common.py
index 5730ac3..7801b59 100644
--- a/rsa/common.py
+++ b/rsa/common.py
@@ -22,20 +22,6 @@ def bit_size(num):
Number of bits needed to represent a integer excluding any prefix
0 bits.
- >>> bit_size(1023)
- 10
- >>> bit_size(1024)
- 11
- >>> bit_size(1025)
- 11
-
- >>> bit_size(1 << 1024)
- 1025
- >>> bit_size((1 << 1024) + 1)
- 1025
- >>> bit_size((1 << 1024) - 1)
- 1024
-
:param num:
Integer value. If num is 0, returns 0. Only the absolute value of the
number is considered. Therefore, signed integers will be abs(num)
@@ -118,9 +104,10 @@ def extended_gcd(a, b):
if (ly < 0): ly += oa #If neg wrap modulo orignal a
return (a, lx, ly) #Return only positive values
+
def inverse(x, n):
"""Returns x^-1 (mod n)
-
+
>>> inverse(7, 4)
3
>>> (inverse(143, 4) * 143) % 4