From d6e0f71c9c1458d58177a6a76cc735f7aee500f8 Mon Sep 17 00:00:00 2001 From: Florian Burgener <florian.brgnr@gmail.com> Date: Fri, 14 Jan 2022 14:50:00 +0100 Subject: [PATCH] Update README + refactoring break_encryption.py --- tmp.md => README.md | 4 ++-- rsa.py => break_encryption.py | 43 +++++++++++++++++------------------ 2 files changed, 23 insertions(+), 24 deletions(-) rename tmp.md => README.md (99%) rename rsa.py => break_encryption.py (93%) diff --git a/tmp.md b/README.md similarity index 99% rename from tmp.md rename to README.md index 3002571..73b171c 100644 --- a/tmp.md +++ b/README.md @@ -1,7 +1,7 @@ # Travail Pratique RSA -Cours : IT 121 – 2021-2022 +Cours : ISC_121 - 2021-2022 -Groupe 13 : Florian BURGENER, Gawen ACKERMANN, Quentin FASLER, Dario GENGA +Groupe : Gawen ACKERMANN, Florian BURGENER, Quentin FASLER, Dario GENGA ## Introduction diff --git a/rsa.py b/break_encryption.py similarity index 93% rename from rsa.py rename to break_encryption.py index df7401d..7f4ccf8 100644 --- a/rsa.py +++ b/break_encryption.py @@ -1,7 +1,6 @@ """ Project : Travail Pratique RSA -Course : ISC_121 – 2021-2022 -Authors : Dario GENGA, Florian BURGENER, Gawen ACKERMANN, Quentin FASLER, +Authors : Gawen ACKERMANN, Florian BURGENER, Quentin FASLER, Dario GENGA Date : 2021-2022 """ import math @@ -53,25 +52,6 @@ def modular_inverse(a, n): return None -def break_encryption(n): - """Breaks RSA encryption using the brute force technique. - - Args: - n (int): The component of the public key which is the product of p and q. - - Returns: - tuple: The prime numbers p and q. - """ - range_low = 3 - range_high = int(math.ceil(math.sqrt(n))) - - for x in [2] + list(range(range_low, range_high, 2)): - if n % x == 0: - return (x, n // x) - - return None - - def modular_pow(base, exponent, modulus): """Computes the modular exponentiation. @@ -99,10 +79,29 @@ def modular_pow(base, exponent, modulus): return result +def break_encryption(n): + """Breaks RSA encryption using the brute force technique. + + Args: + n (int): The component of the public key which is the product of p and q. + + Returns: + tuple: The prime numbers p and q. + """ + range_low = 3 + range_high = int(math.ceil(math.sqrt(n))) + + for x in [2] + list(range(range_low, range_high, 2)): + if n % x == 0: + return (x, n // x) + + return None + + def main(): e = 5249 n = 1653973759 - encrypted_data = (1511395078, 260436590, 1630654276, 1190458520, 790492067, 515550941, 297140366, 755589582, 647075331, 1191707844, 901889430, 660956124, 1500654109, 984322720, 1275630738, 1244853107, 1445928913, 1312523810, 265093060, 933013993, 1375592761, 195866064, 534502441, 928270408, 166404031, 621272622, 1304987439, 905393335, 55120151, 772595721, 506609577, 1172751778, 162439707, 233959833, 1468937795, 1358701120, 901889430, 495995733, 1524090698, 1043509086, 934992314, 1545639379, 1061595897, 1348452679, 1135067876, 905393335, 621272622, 55120151, 233959833, 1220119699, 708711266, 517797467, 195866064, 1579814353, 412378626, 498875436, 445485200, 7656659) + encrypted_data = [1511395078, 260436590, 1630654276, 1190458520, 790492067, 515550941, 297140366, 755589582, 647075331, 1191707844, 901889430, 660956124, 1500654109, 984322720, 1275630738, 1244853107, 1445928913, 1312523810, 265093060, 933013993, 1375592761, 195866064, 534502441, 928270408, 166404031, 621272622, 1304987439, 905393335, 55120151, 772595721, 506609577, 1172751778, 162439707, 233959833, 1468937795, 1358701120, 901889430, 495995733, 1524090698, 1043509086, 934992314, 1545639379, 1061595897, 1348452679, 1135067876, 905393335, 621272622, 55120151, 233959833, 1220119699, 708711266, 517797467, 195866064, 1579814353, 412378626, 498875436, 445485200, 7656659] p, q = break_encryption(n) -- GitLab