Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DuniterPy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
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
Show more breadcrumbs
clients
python
DuniterPy
Commits
326039cf
Commit
326039cf
authored
8 years ago
by
Vincent Texier
Browse files
Options
Downloads
Patches
Plain Diff
add save_private_keys example
parent
2d69bd3e
No related branches found
No related tags found
1 merge request
!33
add save_private_keys example
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/save_private_keys.py
+34
-0
34 additions, 0 deletions
examples/save_private_keys.py
with
34 additions
and
0 deletions
examples/save_private_keys.py
0 → 100644
+
34
−
0
View file @
326039cf
from
duniterpy.key
import
SigningKey
import
getpass
# CONFIG #######################################
# WARNING : Hide this file in a safe and secure place
# If one day you forget your credentials,
# you'll have to use one of your private keys instead
PRIVATE_KEYS_FILE_PATH
=
"
/home/vit/.duniter_account_private_keys.txt
"
################################################
# prompt hidden user entry
salt
=
getpass
.
getpass
(
"
Enter your passphrase (salt):
"
)
# prompt hidden user entry
password
=
getpass
.
getpass
(
"
Enter your password:
"
)
# prompt public key
pubkey
=
input
(
"
Enter your public key:
"
)
# init signer instance
signer
=
SigningKey
(
salt
,
password
)
\
# check public key
if
signer
.
pubkey
!=
pubkey
:
print
(
"
Bad credentials !
"
)
exit
(
0
)
# save private keys in a file (json format)
signer
.
save
(
PRIVATE_KEYS_FILE_PATH
)
# document saved
print
(
"
Private keys for public key %s saved in %s
"
%
(
pubkey
,
PRIVATE_KEYS_FILE_PATH
))
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