Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
ssic_idea
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
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
dario.genga
ssic_idea
Commits
c66ce33e
Commit
c66ce33e
authored
2 years ago
by
dario.genga
Browse files
Options
Downloads
Patches
Plain Diff
Add missing modulos
parent
b8494214
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.py
+8
-9
8 additions, 9 deletions
main.py
with
8 additions
and
9 deletions
main.py
+
8
−
9
View file @
c66ce33e
...
...
@@ -179,7 +179,7 @@ def get_bezout_coefficients(a, b):
y
=
[
0
,
1
]
while
True
:
r
.
append
(
r
[
i
-
2
]
%
r
[
i
-
1
])
r
.
append
(
modulo
(
r
[
i
-
2
]
,
r
[
i
-
1
])
)
# Continue until the rest is equal to 0
if
r
[
i
]
==
0
:
...
...
@@ -215,7 +215,7 @@ def modular_inverse(a, b):
return
None
if
bezout
==
1
and
modulo
(
a
*
x
,
b
)
==
1
:
return
format
(
x
%
b
,
STRING_BINARY_FORMAT
)
return
format
(
modulo
(
x
,
b
)
,
STRING_BINARY_FORMAT
)
return
None
...
...
@@ -231,7 +231,7 @@ def inverse_add_mod(a):
if
type
(
a
)
==
str
:
a
=
int
(
a
,
BINARY_BASE
)
res
=
NIBBLE_BIT_SIZE
-
a
res
=
modulo
(
-
a
,
NIBBLE_BIT_SIZE
)
return
format
(
res
,
STRING_BINARY_FORMAT
)
...
...
@@ -373,15 +373,14 @@ def encrypt(plaintext, subkeys):
res_10
=
add_mod
(
res_7
,
res_9
)
# 11. Bitwise XOR the results of steps 1 and 9
res_11
=
xor
(
res_1
,
res_9
)
# 12. Bitwise XOR the results of steps
3
and
9
res_12
=
xor
(
res_
3
,
res_
9
)
# 13. Bitwise XOR the results of steps
2
and
10
res_13
=
xor
(
res_
2
,
res_
10
)
# 12. Bitwise XOR the results of steps
2
and
10
res_12
=
xor
(
res_
2
,
res_
10
)
# 13. Bitwise XOR the results of steps
3
and
9
res_13
=
xor
(
res_
3
,
res_
9
)
# 14. Bitwise XOR the results of steps 4 and 10
res_14
=
xor
(
res_4
,
res_10
)
# Create the input for the next round with the final results
# The results of the steps 12 and 13 are swapped
input_block
=
res_11
+
res_13
+
res_12
+
res_14
input_block
=
res_11
+
res_12
+
res_13
+
res_14
current_round
+=
1
...
...
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