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


TypeScript crypto.ECDH类代码示例

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


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

示例1:

        N: 16384,
        r: 8,
        p: 1,
        maxmem: 32 * 1024 * 1024
    };
    crypto.scrypt(pwd, salt, 64, opts, (err: Error | null, derivedKey: Buffer): void => {});
    crypto.scrypt(pwd, salt, 64, { maxmem: 16 * 1024 * 1024 }, (err: Error | null, derivedKey: Buffer): void => {});
    let buf: Buffer = crypto.scryptSync(pwd, salt, 64);
    buf = crypto.scryptSync(pwd, salt, 64, opts);
    buf = crypto.scryptSync(pwd, salt, 64, { N: 1024 });
}

{
    let key: string | Buffer = Buffer.from("buf");
    const curve = "secp256k1";
    let ret: string | Buffer = crypto.ECDH.convertKey(key, curve);
    key = "0xfff";
    ret = crypto.ECDH.convertKey(key, curve);
    ret = crypto.ECDH.convertKey(key, curve, "hex");
    ret = crypto.ECDH.convertKey(key, curve, "hex", "hex");
    ret = crypto.ECDH.convertKey(key, curve, "hex", "hex", "uncompressed");
    ret = crypto.ECDH.convertKey(key, curve, "hex", "hex", "compressed");
    ret = crypto.ECDH.convertKey(key, curve, "hex", "hex", "hybrid");
}

{
    const rsaRes: {
        publicKey: Buffer;
        privateKey: string;
    } = crypto.generateKeyPairSync('rsa', {
        modulusLength: 123,
开发者ID:SaschaNaz,项目名称:DefinitelyTyped,代码行数:31,代码来源:crypto.ts

示例2: constructor

 /**
  * @param privKey The 3-part tiForms private key, in the form:
  *                `base64URL(x)|base64URL(y)|base64URL(d)`
  */
 constructor(privKey: string) {
     const keyParts = privKey.split("|");
     const dBase64 = Base64.makeStandard(keyParts[2]);
     this.privKey = createECDH("prime256v1");
     this.privKey.setPrivateKey(dBase64, 'base64');
 }
开发者ID:tera-insights,项目名称:tiFormEncrypt,代码行数:10,代码来源:DecryptorNode.ts

示例3: decryptString

    decryptString(data: EncryptedData): string
    {
        const
            secret = this.privKey.computeSecret(pubKeyToBuffer(data.pubKey)),
            iv = Buffer.alloc(16, 0),
            cipher = createDecipheriv("aes-256-cbc", secret, iv);

        let decrypted = cipher.update(data.payload, "base64", "utf8");
        decrypted += cipher.final("utf8");
        return decrypted;
    }
开发者ID:tera-insights,项目名称:tiFormEncrypt,代码行数:11,代码来源:DecryptorNode.ts


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