crypto

package
v0.0.0-...-db43ba2 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SHA256Hash

func SHA256Hash(data []byte) []byte

SHA256Hash computes SHA256 hash of data and returns hash in []byte format.

func SHA256ToBase64

func SHA256ToBase64(hashed []byte) string

SHA256ToBase64 encoded hashed value to base64 format.

func Sign

func Sign(privateKey *rsa.PrivateKey, hash crypto.Hash, hashed []byte) ([]byte, error)

Sign calculated the RSA signature of hashed value using RSA private key.

To generate hash you can use generate.SHA256Hash function.

func VerifySignature

func VerifySignature(publicKey *rsa.PublicKey, hash crypto.Hash, hashed []byte, signature []byte) bool

VerifySignature verifies the RSA signature using RSA public key and hashed value. Note that you should calculate hash again in order to prevent any modification in transport (MITM attack).

To generate hash you can use generate.SHA256Hash function.

Types

This section is empty.

Jump to

Keyboard shortcuts

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