비트코인 공부

니모닉 <=> 비밀키(엔트로피) 변환 파이썬 코드

bitlog 2023. 2. 2. 08:26

먼저 Mnemonic 모듈 설치

pip install Mnemonic

 

like this

>>> from mnemonic import Mnemonic
>>> from bitcoin import sha256
>>>
>>> m = Mnemonic('english')
>>> priv = sha256('xxxx')
>>> priv
'2481a63c85a62cf889d2b149f1a52e985a9341750173fe01eff50cc27b5941b5'
>>> words = m.to_mnemonic(bytes.fromhex(priv))
>>> words
'cause artwork monkey area glare labor chef file enemy minor entry cost powder pass staff common wrap author wool book chicken protect almost plastic'
>>> priv2 = bytearray.hex(m.to_entropy(words))
>>> priv2
'2481a63c85a62cf889d2b149f1a52e985a9341750173fe01eff50cc27b5941b5'
>>> priv
'2481a63c85a62cf889d2b149f1a52e985a9341750173fe01eff50cc27b5941b5'
728x90
반응형