mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-09 15:58:48 +00:00
Add SeedQR encoding and test
This commit is contained in:
14
src/password_manager/seedqr.py
Normal file
14
src/password_manager/seedqr.py
Normal 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)
|
Reference in New Issue
Block a user