Skip to content

Commit

Permalink
use getpass for input of password
Browse files Browse the repository at this point in the history
  • Loading branch information
monty committed Jun 5, 2024
1 parent 5a437fb commit e3532d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
3 changes: 2 additions & 1 deletion examples/key_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sys
import os
import asyncio
from getpass import getpass
import logging
from pathlib import Path
from monstr.ident.keystore import SQLiteKeyStore, KeystoreInterface, KeyDataEncrypter, NamedKeys
Expand All @@ -19,7 +20,7 @@

async def get_key() -> str:
# get password to unlock keystore
return input('keystore key: ')
return getpass('keystore key: ')


async def get_store() -> KeystoreInterface:
Expand Down
17 changes: 7 additions & 10 deletions my_scratch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import logging
from getpass import getpass
from hashlib import sha256
from monstr.ident.keystore import NamedKeys, FileKeyStore, KeyDataEncrypter, SQLiteKeyStore
from monstr.ident.persist import MemoryProfileStore
Expand All @@ -8,32 +9,28 @@
logging.getLogger().setLevel(logging.DEBUG)


async def get_key() -> str:
# will block, use aiconsole where it matters
return getpass('keystore key: ')


async def convert_store():
# load the old data as alias stores it
old_file = '/home/monty/.nostrpy/profiles.csv'

# create a new key store and copy name/key maps in
new_file = '/home/monty/.nostrpy/keystore.db'


async def get_key() -> str:
# will block, use aiconsole where it matters
return input('keystore key: ')

my_enc = KeyDataEncrypter(get_key=get_key)
new_store = SQLiteKeyStore(new_file,
encrypter=None)
encrypter=my_enc)

await new_store.convert_memstore(old_file)



async def test_store():
# create a new key store and copy name/key maps in
new_file = '/home/monty/.nostrpy/keystore.db'
async def get_key() -> str:
# will block, use aiconsole where it matters
return input('keystore key: ')

my_enc = KeyDataEncrypter(get_key=get_key)

Expand Down

0 comments on commit e3532d2

Please sign in to comment.