gosigner

package module
v0.0.0-...-3ca5d8f Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

README

go-signer

Module for sign objects

type SignableObject struct {
    Id int
    Value string
}

func (o SignableObject) SignString() string {
	return fmt.Sprintf("MyObject_%d",id)
}

signer := gosigner.New(gosigner.SHA256)
object := SignableObject{
    Id: 22,
    Value: "object",
}

sign, err := signer.SignToBase64(ojbject, privkey)

valid, err := signer.VerifyFromBase64(testSignable, sign, pubkey)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sha256Signer

type Sha256Signer struct {
}

func (Sha256Signer) Sign

func (signer Sha256Signer) Sign(s Signable, key string) ([]byte, error)

func (Sha256Signer) SignToBase64

func (signer Sha256Signer) SignToBase64(s Signable, private_key string) (string, error)

func (Sha256Signer) Verify

func (signer Sha256Signer) Verify(s Signable, sign []byte, pubkey string) (bool, error)

func (Sha256Signer) VerifyFromBase64

func (signer Sha256Signer) VerifyFromBase64(s Signable, sign string, pubkey string) (bool, error)

type Signable

type Signable interface {
	SignString() string
}

type Signer

type Signer interface {
	Sign(s Signable, privkey string) ([]byte, error)
	SignToBase64(s Signable, privkey string) (string, error)
	Verify(s Signable, sign []byte, pubkey string) (bool, error)
	VerifyFromBase64(s Signable, sign string, pubkey string) (bool, error)
}

func New

func New(t SignerType) Signer

type SignerType

type SignerType int
const (
	SHA256 SignerType = iota
)

Jump to

Keyboard shortcuts

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