duanniwu7730 2017-12-21 13:22
浏览 68

如何使用openpgp在Go中清除签名和加密

My goal is to use read a PEM file (which contains a private key) and a passphrase to clearsign a file and then use openpgp to encrypt it using a public key that has been provided to me.

I know I should use block, _ := pem.Decode([]byte(pemFile)) to read the file and the ParsePKCS1PrivateKey but I am not sure how to clear sign the file using the key and the passphrase and then encrypt the signed using golang.org/x/crypto/openpgp

Reading the pem file and creating a private key is straightforward:

data, err := ioutil.ReadFile("myPemFile")
block, _ := pem.Decode([]byte(data))
key, err := x509.ParsePKCS1PrivateKey(block.Bytes)

where the key is *rsa.PrivateKey. The question is how to use a passphrase and the private key to clear sign a file i.e. doing something equivalent to:

gpg --batch --passphrase-file <passfile> --clearsign <unsigned file> 
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度