Skip to content

Commit

Permalink
Update: README.md doc example
Browse files Browse the repository at this point in the history
  • Loading branch information
meherett committed Oct 14, 2023
1 parent 34926f4 commit 2f53c3e
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
[![Documentation Status](https://readthedocs.org/projects/bip38/badge/?version=master)](https://bip38.readthedocs.io)
[![PyPI License](https://img.shields.io/pypi/l/bip38?color=black)](https://pypi.org/project/bip38)
[![PyPI Python Version](https://img.shields.io/pypi/pyversions/bip38.svg)](https://pypi.org/project/bip38)
[![Coverage Status](https://coveralls.io/repos/github/meherett/python-bip38/badge.svg?branch=master)](https://coveralls.io/github/meherett/python-bip38)

[comment]: <> ([![Coverage Status]&#40;https://coveralls.io/repos/github/meherett/python-bip38/badge.svg?branch=master&#41;]&#40;https://coveralls.io/github/meherett/python-bip38&#41;)

Python library for implementation of Bitcoin Improvement Proposal - 0038 / BIP38 protocol. It supports both [No EC-multiply](https://github.com/bitcoin/bips/blob/master/bip-0038.mediawiki#encryption-when-ec-multiply-flag-is-not-used) and [EC-multiply](https://github.com/bitcoin/bips/blob/master/bip-0038.mediawiki#encryption-when-ec-multiply-mode-is-used) modes.

Expand Down Expand Up @@ -39,14 +40,18 @@ pip install git+git://github.com/meherett/python-bip38.git
from bip38 import (
private_key_to_wif, bip38_encrypt, bip38_decrypt
)
from typing import List
from typing import (
List, Literal
)

import json

# Private key
PRIVATE_KEY: str = "cbf4b9f70470856bb4f40f80b87edb90865997ffee6df315ab166d713af433a5"
# Passphrase / password
PASSPHRASE: str = "meherett" # u"\u03D2\u0301\u0000\U00010400\U0001F4A9"
# Network type
NETWORK: Literal["mainnet", "testnet"] = "mainnet"
# To show detail
DETAIL: bool = True
# Wallet important format's
Expand All @@ -60,12 +65,12 @@ for WIF in WIFs:
print("WIF:", WIF)

encrypted_wif: str = bip38_encrypt(
wif=WIF, passphrase=PASSPHRASE
wif=WIF, passphrase=PASSPHRASE, network=NETWORK
)
print("BIP38 Encrypted WIF:", encrypted_wif)

print("BIP38 Decrypted:", json.dumps(bip38_decrypt(
encrypted_wif=encrypted_wif, passphrase=PASSPHRASE, detail=DETAIL
encrypted_wif=encrypted_wif, passphrase=PASSPHRASE, network=NETWORK, detail=DETAIL
), indent=4))

print("-" * 125)
Expand Down Expand Up @@ -114,13 +119,17 @@ BIP38 Decrypted: {
from bip38 import (
intermediate_code, create_new_encrypted_wif, confirm_code, bip38_decrypt
)
from typing import List
from typing import (
List, Literal
)

import json
import os

# Passphrase / password
PASSPHRASE: str = "meherett" # u"\u03D2\u0301\u0000\U00010400\U0001F4A9"
# Network type
NETWORK: Literal["mainnet", "testnet"] = "mainnet"
# To show detail
DETAIL: bool = True
# List of samples with owner salt, seed, public key type, lot, and sequence
Expand Down Expand Up @@ -151,16 +160,16 @@ for SAMPLE in SAMPLES:
print("Intermediate Passphrase:", intermediate_passphrase)

encrypted_wif: dict = create_new_encrypted_wif(
intermediate_passphrase=intermediate_passphrase, public_key_type=SAMPLE["public_key_type"], seed=SAMPLE["seed"]
intermediate_passphrase=intermediate_passphrase, public_key_type=SAMPLE["public_key_type"], seed=SAMPLE["seed"], network=NETWORK
)
print("Encrypted WIF:", json.dumps(encrypted_wif, indent=4))

print("Confirm Code:", json.dumps(confirm_code(
passphrase=PASSPHRASE, confirmation_code=encrypted_wif["confirmation_code"], detail=DETAIL
passphrase=PASSPHRASE, confirmation_code=encrypted_wif["confirmation_code"], network=NETWORK, detail=DETAIL
), indent=4))

print("BIP38 Decrypted:", json.dumps(bip38_decrypt(
encrypted_wif=encrypted_wif["encrypted_wif"], passphrase=PASSPHRASE, detail=DETAIL
encrypted_wif=encrypted_wif["encrypted_wif"], passphrase=PASSPHRASE, network=NETWORK, detail=DETAIL
), indent=4))

print("-" * 125)
Expand Down

0 comments on commit 2f53c3e

Please sign in to comment.