本文整理汇总了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;未经允许,请勿转载。 |
请发表评论