Skip to content
Snippets Groups Projects
Commit d6e0f71c authored by Florian Burgener's avatar Florian Burgener
Browse files

Update README + refactoring break_encryption.py

parent 15a84397
No related branches found
No related tags found
No related merge requests found
# 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
......
"""
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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment