當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript crypto.createVerify函數代碼示例

本文整理匯總了TypeScript中crypto.createVerify函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript createVerify函數的具體用法?TypeScript createVerify怎麽用?TypeScript createVerify使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了createVerify函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: QueryProcessManager

export const PM = new QueryProcessManager(module, async ({data, signature}) => {
	const verifier = crypto.createVerify(Config.loginserverkeyalgo);
	verifier.update(data);
	let success = false;
	try {
		success = verifier.verify(Config.loginserverpublickey, signature, 'hex');
	} catch (e) {}

	return success;
});
開發者ID:Zarel,項目名稱:Pokemon-Showdown,代碼行數:10,代碼來源:verifier.ts

示例2: if

 client.on('authentication', ctx => {
     if (ctx.method === 'password'
         && ctx.username === 'foo'
         && ctx.password === 'bar')
         ctx.accept();
     else if (ctx.method === 'publickey'
         && ctx.key.algo === pubKey.fulltype
         && buffersEqual(ctx.key.data, pubKey.public)) {
         if (ctx.signature) {
             var verifier = crypto.createVerify(ctx.sigAlgo);
             verifier.update(ctx.blob);
             if (verifier.verify(pubKey.publicOrig.toString("utf8"), ctx.signature))
                 ctx.accept();
             else
                 ctx.reject();
         } else {
             // if no signature present, that means the client is just checking
             // the validity of the given public key
             ctx.accept();
         }
     } else
         ctx.reject();
 }).on('ready', () => {
開發者ID:Jeremy-F,項目名稱:DefinitelyTyped,代碼行數:23,代碼來源:ssh2-tests.ts

示例3:

{
    crypto.createSecretKey(Buffer.from('asdf'));
}

{
    const { privateKey, publicKey } = crypto.generateKeyPairSync('ec', {
        namedCurve: 'sect239k1'
    });

    const sign: crypto.Signer = crypto.createSign('SHA256');
    sign.write('some data to sign');
    sign.end();
    const signature: string = sign.sign(privateKey, 'hex');

    const verify: crypto.Verify = crypto.createVerify('SHA256');
    verify.write('some data to sign');
    verify.end();
    verify.verify(publicKey, signature);    // $ExpectType boolean

    // ensure that instanceof works
    verify instanceof crypto.Verify;
    sign instanceof crypto.Signer;
}

{
    const { privateKey, publicKey } = crypto.generateKeyPairSync('rsa', {
        modulusLength: 2048,
    });

    const sign: crypto.Signer = crypto.createSign('SHA256');
開發者ID:ChaosinaCan,項目名稱:DefinitelyTyped,代碼行數:30,代碼來源:crypto.ts

示例4: function

export const verify = function(data, signature, key) {
    let verifier = crypto.createVerify('RSA-SHA1')
    verifier.update(data, 'utf8')

    return verifier.verify(key, signature, 'base64')
}
開發者ID:danibram,項目名稱:trustly-client,代碼行數:6,代碼來源:utils.ts

示例5: verifySignature

export function verifySignature(message: string, signature: string, pandaPublicKey: string): boolean {
    return crypto.createVerify('sha256WithRSAEncryption')
        .update(message, 'utf8')
        .verify(pandaPublicKey, signature, 'base64');
}
開發者ID:guardian,項目名稱:pan-domain-authentication,代碼行數:5,代碼來源:utils.ts


注:本文中的crypto.createVerify函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。