signature

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 私钥 PEMBEGIN 开头
	PEMBEGIN = "-----BEGIN RSA PRIVATE KEY-----\n"
	// 私钥 PEMEND 结尾
	PEMEND = "\n-----END RSA PRIVATE KEY-----"
	// 公钥 PEMBEGIN 开头
	PUBPEMBEGIN = "-----BEGIN PUBLIC KEY-----\n"
	// 公钥 PEMEND 结尾
	PUBPEMEND = "\n-----END PUBLIC KEY-----"
)

Variables

View Source
var ErrPemDecode = errors.New("pem.Decode failed") // pem解析失败

Functions

func FormatPublicKey

func FormatPublicKey(publicKey string) string

FormatPublicKey 组装公钥

func ParsePublicKey

func ParsePublicKey(publicKey string) (*rsa.PublicKey, error)

ParsePublicKey 公钥验证

func Rsa2PubSign

func Rsa2PubSign(signContent, sign, publicKey string, hash crypto.Hash) (err error)

Rsa2PubSign RSA2公钥验证签名

func VerifySign

func VerifySign(content, sign string, pubKeys []string) (err error)

Types

type Sign

type Sign func(content, privateKey string) (sign string, err error)

Sign 加签函数

type Signer

type Signer struct {
	S Sign
}

func NewSigner

func NewSigner(s Sign) *Signer

NewSigner 初始化Signer,默认RSA2签名

func (*Signer) Sign

func (s *Signer) Sign(content, privateKey string) (sign string, err error)

type Verifier

type Verifier struct {
	V Verify
}

func NewRSA2Verifier

func NewRSA2Verifier() *Verifier

func NewVerifier

func NewVerifier(v Verify) *Verifier

func (*Verifier) Verify

func (s *Verifier) Verify(content, sign, pubKey string) (err error)

type Verify

type Verify func(content, sign, pubKey string) (err error)

Verify 验签函数

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL