golembase python sdk readme [1] suggests to work with private.key files that store private keys in plain text. this issue proposes to work with wallet json files instead [1]
proposal for wallet.py
import getpass
import json
import sys
from pathlib import Path
from eth_account import Account
WALLET_PATH = Path("wallet.json")
if WALLET_PATH.exists():
print(f'File "{WALLET_PATH}" already exists. Aborting.')
sys.exit(0)
password = getpass.getpass("Enter wallet password: ")
account = Account.create()
encrypted = account.encrypt(password)
with WALLET_PATH.open("w") as f:
json.dump(encrypted, f)
print(f"Account address: {account.address}")
print(f"Wallet file: {WALLET_PATH}")
and reconstructing the privat key from the wallet file
with WALLET_PATH.open("r") as f:
wallet_json = json.load(f)
private_key = Account.decrypt(wallet_json, password)