Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ISC_121 - Travail Pratique 002 - RSA
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
florian.burgener
ISC_121 - Travail Pratique 002 - RSA
Commits
d6e0f71c
Commit
d6e0f71c
authored
3 years ago
by
Florian Burgener
Browse files
Options
Downloads
Patches
Plain Diff
Update README + refactoring break_encryption.py
parent
15a84397
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+2
-2
2 additions, 2 deletions
README.md
break_encryption.py
+21
-22
21 additions, 22 deletions
break_encryption.py
with
23 additions
and
24 deletions
tmp
.md
→
README
.md
+
2
−
2
View file @
d6e0f71c
# Travail Pratique RSA
Cours : I
T
121
–
2021-2022
Cours : I
SC_
121
-
2021-2022
Groupe
13 : Florian BURGENER, Gawen ACKERMANN
, Quentin FASLER, Dario GENGA
Groupe
: Gawen ACKERMANN, Florian BURGENER
, Quentin FASLER, Dario GENGA
## Introduction
...
...
This diff is collapsed.
Click to expand it.
rsa
.py
→
break_encryption
.py
+
21
−
22
View file @
d6e0f71c
"""
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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment