CNode

关于Google Pay问题

问答
Iim-here发布于10 年前最后回复10 年前7 回复5567 浏览0 收藏

有人用node做个google pay吗? 网上搜下了只找到了php版本的支付验证,代码如下

1111111111111111111111111111111111111111111111111.jpg 有几个函数想问问用node怎么实现啊 1.openssl_get_publickey 2.openssl_verify

查看回复

回复 (7)

M
MiguelValentine#1·10 年前

openssl_get_publickey 不用实现。 openssl_verify的例子

var RsaSha1Check = function(str,publicKey,sig){
    var verify = crypto.createVerify('RSA-SHA1');
    verify.update(str,'utf8');
    var result = verify.verify(publicKey,decodeURIComponent(sig),'base64');
    return result;
};
I
im-here#2·10 年前
引用 MiguelValentineopenssl get publickey 不用实现。 openssl verify的例子

@MiguelValentine 谢谢你的回答。 你这个函数最后返回的结果result是不是就是上面示例里的$result了?

I
im-here#4·10 年前
引用 MiguelValentine@imhered 我反回的是布尔。true/false

@MiguelValentine 嗯 调了下 好像是这样的,我还在测试中,非常感谢!

I
im-here#5·10 年前
引用 MiguelValentine@imhered 我反回的是布尔。true/false

@MiguelValentine 验证了半天一直都是false。在请教几个问题 1.verify.update(str,'utf8'); 这个编码为什么是utf8呢? 2.为什么要decodeURIComponent(sig)?

参与回复
登录后即可参与回复。登录