Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Cryptography
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
Container registry
Model registry
Operate
Environments
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
Show more breadcrumbs
Prajczer Péter
Cryptography
Commits
d4e5951d
Commit
d4e5951d
authored
5 years ago
by
Prajczer Péter
Browse files
Options
Downloads
Patches
Plain Diff
added finished code for lab1
parent
ee9b0dc4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitignore
+2
-0
2 additions, 0 deletions
.gitignore
ITKoin_01_Prajczer_Peter.py
+12
-9
12 additions, 9 deletions
ITKoin_01_Prajczer_Peter.py
with
14 additions
and
9 deletions
.gitignore
0 → 100644
+
2
−
0
View file @
d4e5951d
/.idea/
*.pem
This diff is collapsed.
Click to expand it.
ITKoin_01_Prajczer_Peter.py
+
12
−
9
View file @
d4e5951d
...
...
@@ -61,6 +61,7 @@ class ITKoin:
rsakey
=
RSA
.
import_key
(
publickeyfilecontent
)
rsapublickey
=
rsakey
.
publickey
()
self
.
rsapublickey
=
rsapublickey
return
rsapublickey
# pprint(vars(self.rsapublickey))
...
...
@@ -93,20 +94,22 @@ class ITKoin:
# hozz létre egy verify objektumot
verifyobject
=
pkcs1_15
.
new
(
rsapublickey
)
# az adatot töltsd be egy hash objektumba a create_hashobject(data) használatával
hashobject
=
self
.
create_hashobject
(
data
)
hashobject
=
self
.
create_hashobject
(
data
)
# dekódold base64 kódolással az aláírás értéket
signaturevalue
=
b64decode
(
b64signaturevalue
)
signatureerror
=
verifyobject
.
verify
(
signaturevalue
,
hashobject
)
# értéke: True, ha az aláírás érvényes
validsignature
=
True
return
validsignature
signaturevalue
=
b64decode
(
b64signaturevalue
)
# ellenőrizd az aláírást
try
:
verifyobject
.
verify
(
hashobject
,
signaturevalue
)
except
ValueError
:
return
False
return
True
if
__name__
==
'
__main__
'
:
test_coin
=
ITKoin
()
# test_coin.generate_rsa_key("prajczer")
test_coin
.
load_key
(
"
prajczer
"
)
test_coin
.
load_public_key
(
"
prajczer
"
)
rsapublickey
=
test_coin
.
load_public_key
(
"
prajczer
"
)
test_coin
.
create_hashobject
(
"
random
"
)
test_coin
.
create_signature
(
'
random
'
)
test_coin
.
verify_signature
(
@fasz
kivan
)
signo
=
test_coin
.
create_signature
(
'
random
'
)
test_coin
.
verify_signature
(
'
random
'
,
signo
,
rsapublickey
)
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