Merge pull request #266 from PR0M3TH3AN/codex/add-show-seedqr-option

Add SeedQR display option
This commit is contained in:
thePR0M3TH3AN
2025-07-05 07:42:56 -04:00
committed by GitHub
3 changed files with 33 additions and 0 deletions

View File

@@ -1273,6 +1273,10 @@ class PasswordManager:
else:
print(colored("\n[+] Retrieved Seed Phrase:\n", "green"))
print(colored(phrase, "yellow"))
if confirm_action("Show SeedQR? (Y/N): "):
from password_manager.seedqr import encode_seedqr
TotpManager.print_qr_code(encode_seedqr(phrase))
if confirm_action("Show derived entropy as hex? (Y/N): "):
from local_bip85.bip85 import BIP85
from bip_utils import Bip39SeedGenerator

View File

@@ -0,0 +1,14 @@
"""SeedQR encoding utilities."""
from __future__ import annotations
from bip_utils.bip.bip39.bip39_mnemonic import Bip39Languages
from bip_utils.bip.bip39.bip39_mnemonic_utils import Bip39WordsListGetter
def encode_seedqr(mnemonic: str) -> str:
"""Return SeedQR digit stream for a BIP-39 mnemonic."""
wordlist = Bip39WordsListGetter().GetByLanguage(Bip39Languages.ENGLISH)
words = mnemonic.strip().split()
indices = [wordlist.GetWordIdx(word.lower()) for word in words]
return "".join(f"{idx:04d}" for idx in indices)

View File

@@ -0,0 +1,15 @@
import sys
from pathlib import Path
sys.path.append(str(Path(__file__).resolve().parents[1]))
from password_manager.seedqr import encode_seedqr
def test_seedqr_standard_example():
phrase = (
"vacuum bridge buddy supreme exclude milk consider tail "
"expand wasp pattern nuclear"
)
expected = "192402220235174306311124037817700641198012901210"
assert encode_seedqr(phrase) == expected