1 Star 0 Fork 0

eden-w2w / wechatpay-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
wechat_pay_decryptor.go 754 Bytes
一键复制 编辑 原始数据 按行查看 历史
文兄 提交于 2022-01-07 17:45 . change mod name
// Copyright 2021 Tencent Inc. All rights reserved.
package decryptors
import (
"context"
"crypto/rsa"
"gitee.com/eden-w2w/wechatpay-go/utils"
)
// WechatPayDecryptor 微信支付字符串解密器
type WechatPayDecryptor struct {
// 商户私钥
privateKey *rsa.PrivateKey
}
// Decrypt 使用商户私钥对字符串进行解密
func (d *WechatPayDecryptor) Decrypt(_ context.Context, ciphertext string) (plaintext string, err error) {
if ciphertext == "" {
return "", nil
}
return utils.DecryptOAEP(ciphertext, d.privateKey)
}
// NewWechatPayDecryptor 使用商户私钥初始化一个 WechatPayDecryptor
func NewWechatPayDecryptor(privateKey *rsa.PrivateKey) *WechatPayDecryptor {
return &WechatPayDecryptor{privateKey: privateKey}
}
1
https://gitee.com/eden-w2w/wechatpay-go.git
git@gitee.com:eden-w2w/wechatpay-go.git
eden-w2w
wechatpay-go
wechatpay-go
v0.2.12

搜索帮助