Skip to content
Snippets Groups Projects
Commit 326039cf authored by Vincent Texier's avatar Vincent Texier
Browse files

add save_private_keys example

parent 2d69bd3e
No related branches found
No related tags found
1 merge request!33add save_private_keys example
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))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment