erlang大坑——加密和字符串处理

1、问题描述

因业务要求,需要对指定的http请求内容进行RSA签名,并且将签名结果和请求内容用json格式打包。这里包括两个需要处理的点:1、用RSA私钥签名;2、把http请求json化。

2、处理签名

目前项目使用的erlang版本是17.0,这个版本有专门针对RSA的库即public_key,但是查看public_key相关描述
sign(Msg, DigestType, Key) -> binary()

Types:

Msg = binary() | {digest,binary()}
The msg is either the binary "plain text" data to be signed or it is the hashed value of "plain text" i.e. the digest.
DigestType = rsa_digest_type() | dss_digest_type() | ecdsa_digest_type()
Key = rsa_private_key() | dsa_private_key() | ec_private_key()
Creates a digital signature.

明显,参数需要rsa_private_key()类型参数,参数定义

-record('RSAPrivateKey',{
version, modulus, publicExponent, privateExponent, prime1, prime2, exponent1, exponent2, coefficient, otherPrimeInfos = asn1_NOVALUE}).
对于只有privatekey而没有生成key的两个素数的应用场景来说,这个库就是渣,感觉并没有什么卵用。其他方案?
1、http://blog.sina.com.cn/s/blog_48c0f7f10101bh7d.html
2、java和c++应该是有对应的库的,
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值