gosignature

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2021 License: MIT Imports: 8 Imported by: 0

README

MrAndreID / Go Signature

Go Reference

The MrAndreID/GoSignature package is a collection of functions in the go language for Signature with rsa-sha256.


Table of Contents


Install

To use The MrAndreID/GoSignature package, you must follow the steps below:

go get -u github.com/MrAndreID/gosignature

Usage

Generate a Signature
signature, err := gosignature.Generate([]byte(`-----BEGIN RSA PRIVATE KEY-----
MIIBOQIBAAJAfBNTEHscBt+jNL+Ry1aqPoICoM8fuSpCkFN3KZ37zVEWu6Poav56
yp1i5D4ngVQ7vW2w2Go7M8TCfNS4aLna3wIDAQABAkAklCnj7Pd5S0s5TNT1poow
PXH66LVIiJ3xILo7ybincbp2jMc0Ah7TmuoTm9C0Uz8esoKWK2YGkLOykHSPxw25
AiEA2H3uURF/iqz4V5cJscbDMRQHc/qOpr22UF8utCkEMm0CIQCSt+ICBt2Y0Pir
BXjFmM6AcLHqwvy93gtypGx78dvS+wIgYCM0JH3/xGZhdgwVewPIBFBfquo2VOdk
Qbay98BLI9UCIHPzEJELffs0QyFdTKnUbnZBGcpvWLBwl9l9KiL17AUbAiEApiKl
aJkS7fmAd5XGd43BXgWJevG87yUzXxKPbsMp3mk=
-----END RSA PRIVATE KEY-----`), []byte(`Andrea Adam`))

Output:

ZMVHtYqKTgwsBItALtoE71ApBVJSQ1vxtW9a9oiugGZkhpIUBHtKTpL5e29CAeZnwlHTurUxpk1aH2RHx9sx3Q==
Signature Verification
verify, err := gosignature.Verify(signature, []byte(`-----BEGIN PUBLIC KEY-----
MFswDQYJKoZIhvcNAQEBBQADSgAwRwJAfBNTEHscBt+jNL+Ry1aqPoICoM8fuSpC
kFN3KZ37zVEWu6Poav56yp1i5D4ngVQ7vW2w2Go7M8TCfNS4aLna3wIDAQAB
-----END PUBLIC KEY-----`), []byte(`Andrea Adam`))

if verify == false {
    fmt.Println("Signature verification failed because : ", err)
} else {
    fmt.Println("Signature verification was successful")
}

Output:

Signature verification was successful

Full Example

Full Example can be found on the Go Playground website.

Versioning

I use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

Andrea Adam - MrAndreID

License

MIT licensed. See the LICENSE file for details.

Official Documentation for Go Language

Documentation for Go Language can be found on the Go Language website.

More

Documentation can be found on https://go.dev/.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(privateKey []byte, value []byte) (string, error)

func Verify added in v1.1.0

func Verify(signature string, publicKey []byte, value []byte) (bool, error)

Types

type Signer

type Signer interface {
	Sign(data []byte) ([]byte, error)
}

type Unsigner added in v1.1.0

type Unsigner interface {
	Unsign(data []byte, signature []byte) error
}

Jump to

Keyboard shortcuts

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