Document the crypto/ module

This commit is contained in:
Lonami Exo
2017-11-26 16:57:40 +01:00
parent 74ec6391d9
commit a932fb6470
8 changed files with 142 additions and 21 deletions

View File

@@ -1,9 +1,21 @@
"""
This module holds a fast Factorization class.
"""
from random import randint
class Factorization:
"""
Simple module to factorize large numbers really quickly.
"""
@classmethod
def factorize(cls, pq):
"""
Factorizes the given large integer.
:param pq: the prime pair pq.
:return: a tuple containing the two factors p and q.
"""
if pq % 2 == 0:
return 2, pq // 2
@@ -39,6 +51,13 @@ class Factorization:
@staticmethod
def gcd(a, b):
"""
Calculates the Greatest Common Divisor.
:param a: the first number.
:param b: the second number.
:return: GCD(a, b)
"""
while b:
a, b = b, a % b