当前位置: 首页>>代码示例>>Python>>正文


Python Mnemonic.normalize_string方法代码示例

本文整理汇总了Python中mnemonic.Mnemonic.normalize_string方法的典型用法代码示例。如果您正苦于以下问题:Python Mnemonic.normalize_string方法的具体用法?Python Mnemonic.normalize_string怎么用?Python Mnemonic.normalize_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mnemonic.Mnemonic的用法示例。


在下文中一共展示了Mnemonic.normalize_string方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_device_by_mnemonic

# 需要导入模块: from mnemonic import Mnemonic [as 别名]
# 或者: from mnemonic.Mnemonic import normalize_string [as 别名]
    def load_device_by_mnemonic(self, mnemonic, pin, passphrase_protection, label, language, skip_checksum=False):
        m = Mnemonic("english")
        if not skip_checksum and not m.check(mnemonic):
            raise Exception("Invalid mnemonic checksum")

        # Convert mnemonic to UTF8 NKFD
        mnemonic = Mnemonic.normalize_string(mnemonic)

        # Convert mnemonic to ASCII stream
        mnemonic = unicode(str(bytearray(mnemonic, "utf-8")), "utf-8")

        if self.features.initialized:
            raise Exception("Device is initialized already. Call wipe_device() and try again.")

        resp = self.call(
            proto.LoadDevice(
                mnemonic=mnemonic,
                pin=pin,
                passphrase_protection=passphrase_protection,
                language=language,
                label=label,
                skip_checksum=skip_checksum,
            )
        )
        self.init_device()
        return resp
开发者ID:kyuupichan,项目名称:python-keepkey,代码行数:28,代码来源:client.py

示例2: load_device_by_mnemonic

# 需要导入模块: from mnemonic import Mnemonic [as 别名]
# 或者: from mnemonic.Mnemonic import normalize_string [as 别名]
def load_device_by_mnemonic(
    client,
    mnemonic,
    pin,
    passphrase_protection,
    label,
    language="english",
    skip_checksum=False,
    expand=False,
):
    # Convert mnemonic to UTF8 NKFD
    mnemonic = Mnemonic.normalize_string(mnemonic)

    # Convert mnemonic to ASCII stream
    mnemonic = mnemonic.encode()

    m = Mnemonic("english")

    if expand:
        mnemonic = m.expand(mnemonic)

    if not skip_checksum and not m.check(mnemonic):
        raise ValueError("Invalid mnemonic checksum")

    if client.features.initialized:
        raise RuntimeError(
            "Device is initialized already. Call device.wipe() and try again."
        )

    resp = client.call(
        proto.LoadDevice(
            mnemonic=mnemonic,
            pin=pin,
            passphrase_protection=passphrase_protection,
            language=language,
            label=label,
            skip_checksum=skip_checksum,
        )
    )
    client.init_device()
    return resp
开发者ID:trezor,项目名称:python-trezor,代码行数:43,代码来源:debuglink.py

示例3: set_mnemonic

# 需要导入模块: from mnemonic import Mnemonic [as 别名]
# 或者: from mnemonic.Mnemonic import normalize_string [as 别名]
 def set_mnemonic(self, mnemonic):
     self.mnemonic = unicode(str(bytearray(Mnemonic.normalize_string(mnemonic), "utf-8")), "utf-8").split(" ")
开发者ID:kyuupichan,项目名称:python-keepkey,代码行数:4,代码来源:client.py

示例4: set_passphrase

# 需要导入模块: from mnemonic import Mnemonic [as 别名]
# 或者: from mnemonic.Mnemonic import normalize_string [as 别名]
 def set_passphrase(self, passphrase):
     self.passphrase = unicode(str(bytearray(Mnemonic.normalize_string(passphrase), "utf-8")), "utf-8")
开发者ID:kyuupichan,项目名称:python-keepkey,代码行数:4,代码来源:client.py

示例5: set_mnemonic

# 需要导入模块: from mnemonic import Mnemonic [as 别名]
# 或者: from mnemonic.Mnemonic import normalize_string [as 别名]
 def set_mnemonic(self, mnemonic):
     self.mnemonic = Mnemonic.normalize_string(mnemonic).split(" ")
开发者ID:trezor,项目名称:python-trezor,代码行数:4,代码来源:debuglink.py

示例6: set_passphrase

# 需要导入模块: from mnemonic import Mnemonic [as 别名]
# 或者: from mnemonic.Mnemonic import normalize_string [as 别名]
 def set_passphrase(self, passphrase):
     self.ui.passphrase = Mnemonic.normalize_string(passphrase)
开发者ID:trezor,项目名称:python-trezor,代码行数:4,代码来源:debuglink.py


注:本文中的mnemonic.Mnemonic.normalize_string方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。