Skip to content
Snippets Groups Projects
Commit c8ac5a30 authored by adrian.spycher's avatar adrian.spycher
Browse files

add some comment

parent a23a3c55
Branches
No related tags found
No related merge requests found
......@@ -76,7 +76,7 @@ def exponentiation_rapide(a, exp, n):
def is_square(a):
"""Check if a number is a perfect square, using the Newton methode
from https://stackoverflow.com/questions/2489435/check-if-a-number-is-a-perfect-square
from : https://stackoverflow.com/questions/2489435/check-if-a-number-is-a-perfect-square
Args:
a (uint): number checked
......@@ -85,7 +85,7 @@ def is_square(a):
bool: true if the number is a perfect square, otherwise flase
"""
x = a // 2
x = a // 2 # start value
seen = set([x])
while x * x != a:
......@@ -127,6 +127,7 @@ def fermat_factorization(n):
def decode_msg(M):
"""Decode a code UTF-8 in characters
from : Niklaus Eggenberg
Args:
M (uint): code UTF-8
......
......@@ -34,7 +34,7 @@ def main():
q = a - b
fi = (p - 1) * (q - 1)
d = inverse_modulaire(e, fi)
d = inverse_modulaire(e, fi) # get private key
# --- decode mu & initialise msg ---
for i in range(length):
......@@ -43,8 +43,10 @@ def main():
for m in M:
msg += decode_msg(m)
# --- output ---
print("p :", p, "\nq :", q, "\nfi :", fi, "\nd :", d, "\nmsg :", msg)
if __name__ == "__main__":
main()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment