Sha256: cb11cab90c3aa5fd91124fc3f0722cdac2e24c88e965c8f6ccd99a2a4e1eb8f7

Contents?: true

Size: 656 Bytes

Versions: 6

Compression:

Stored size: 656 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 func

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lanmao-0.16.0 lib/lanmao/sign/rsa.rb
lanmao-0.15.0 lib/lanmao/sign/rsa.rb
lanmao-0.14.0 lib/lanmao/sign/rsa.rb
lanmao-0.13.0 lib/lanmao/sign/rsa.rb
lanmao-0.12.0 lib/lanmao/sign/rsa.rb
lanmao-0.11.0 lib/lanmao/sign/rsa.rb