How to use the mnemonic.mnemonic.PBKDF2_ROUNDS function in mnemonic

To help you get started, we’ve selected a few mnemonic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github StellarCN / py-stellar-base / stellar_sdk / sep / mnemonic.py View on Github external
def to_seed(cls, mnemonic: str, passphrase: str = "", index: int = 0) -> bytes:
        mnemonic = cls.normalize_string(mnemonic)
        passphrase = cls.normalize_string(passphrase)
        passphrase = "mnemonic" + passphrase
        mnemonic = mnemonic.encode("utf-8")
        passphrase = passphrase.encode("utf-8")
        stretched = hashlib.pbkdf2_hmac("sha512", mnemonic, passphrase, PBKDF2_ROUNDS)
        return cls.derive(stretched[:64], index)