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


TypeScript signature-generator.utils.crypto类代码示例

本文整理汇总了TypeScript中@waves/signature-generator.utils.crypto的典型用法代码示例。如果您正苦于以下问题:TypeScript utils.crypto类的具体用法?TypeScript utils.crypto怎么用?TypeScript utils.crypto使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: constructor

    constructor(phrase: string) {
        if (phrase.length < get('minimalSeedLength')) {
            throw new Error('Your seed length is less than allowed in config');
        }

        const keys = utils.crypto.buildKeyPair(phrase);

        this.phrase = phrase;
        this.address = utils.crypto.buildRawAddress(keys.publicKey);
        this.keyPair = {
            privateKey: libs.base58.encode(keys.privateKey),
            publicKey: libs.base58.encode(keys.publicKey)
        };

        Object.freeze(this);
        Object.freeze(this.keyPair);

    }
开发者ID:wavesplatform,项目名称:WavesGUI,代码行数:18,代码来源:Seed.ts

示例2: encryptSeedPhrase

    public static encryptSeedPhrase(seedPhrase: string, password: string, encryptionRounds: number = 5000): string {
        if (password && password.length < 8) {
            // logger.warn('Your password may be too weak');
        }

        if (encryptionRounds < 1000) {
            // logger.warn('Encryption rounds may be too few');
        }

        if (seedPhrase.length < get('minimalSeedLength')) {
            throw new Error('The seed phrase you are trying to encrypt is too short');
        }

        return utils.crypto.encryptSeed(seedPhrase, password, encryptionRounds);
    }
开发者ID:wavesplatform,项目名称:WavesGUI,代码行数:15,代码来源:Seed.ts

示例3: _generateNewSeed

    private static _generateNewSeed(length: number): string {

        const random = utils.crypto.generateRandomUint32Array(length);
        const wordCount = dictionary.length;
        const phrase = [];

        for (let i = 0; i < length; i++) {
            const wordIndex = random[i] % wordCount;
            phrase.push(dictionary[wordIndex]);
        }

        random.set(new Uint8Array(random.length));

        return phrase.join(' ');

    }
开发者ID:wavesplatform,项目名称:WavesGUI,代码行数:16,代码来源:Seed.ts

示例4: decryptSeedPhrase

    public static decryptSeedPhrase(encryptedSeedPhrase: string, password: string, encryptionRounds: number = 5000): string {

        const wrongPasswordMessage = 'The password is wrong';

        let phrase;

        try {
            phrase = utils.crypto.decryptSeed(encryptedSeedPhrase, password, encryptionRounds);
        } catch (e) {
            throw new Error(wrongPasswordMessage);
        }

        if (phrase === '' || phrase.length < get('minimalSeedLength')) {
            throw new Error(wrongPasswordMessage);
        }

        return phrase;

    }
开发者ID:wavesplatform,项目名称:WavesGUI,代码行数:19,代码来源:Seed.ts


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