Sha256: 57e2f528dda78e3c41c4e32ef01a3db4aa380d507c41807df132dd5661956f15
Contents?: true
Size: 651 Bytes
Versions: 2
Compression:
Stored size: 651 Bytes
Contents
# coding: utf-8 module Lanmao module Sign module RSA #签名 def self.sign(content, private_key) sign = private_key.sign("sha1", content.force_encoding("utf-8")) signature = Base64.encode64(sign) signature = signature.delete("\n").delete("\r") end ## 验签 def self.verify(data, sign, config) ##如何从data里分离出原始数据和签名数据 if sign sign = Base64.decode64(sign) digester = OpenSSL::Digest::SHA1.new config[:public_key].verify(digester, sign, data) else true end end # verify end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lanmao-0.10.0 | lib/lanmao/sign/rsa.rb |
lanmao-0.9.1 | lib/lanmao/sign/rsa.rb |