crypto

package
v1.23.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: MIT Imports: 18 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSignatureNotValid = fmt.Errorf("Signature not valid")

Functions

func GenerateKey

func GenerateKey(secret, salt string, digest Digest) []byte

Generate a Rails-compatible key

func GenerateKeyWithOptions

func GenerateKeyWithOptions(secret, salt string, iter, size int, hgen HashFunc) []byte

Generate a key with options

func GenerateToken

func GenerateToken(key []byte, digest Digest) (string, string)

Generate a Devise-compatible general-purpose secure token

func NewCertPoolFromCertificatesInDirectory

func NewCertPoolFromCertificatesInDirectory(dir string) (*x509.CertPool, error)

Create a certificate pool containing all the certificates found in the specified directory.

func PKCS5Pad

func PKCS5Pad(in []byte) []byte

Pad an AES block

func PKCS5Unpad

func PKCS5Unpad(in []byte) []byte

Unpad an AES block

func SecureCompare

func SecureCompare(a, b string) bool

Compare strings in constant time

func Sign

func Sign(key []byte, digest Digest, data []byte) string

Sign data using HMAC

func SignMessage

func SignMessage(key []byte, digest Digest, message interface{}) (string, string, error)

Produce a serialized, base64-encoded message and its signature

func Verify

func Verify(key []byte, digest Digest, sig string, data []byte) bool

Verify a signature

func VerifyMessage

func VerifyMessage(key []byte, digest Digest, sig string, message interface{}, data string) error

Validate a message signature and, if valid, unmarshal the message

Types

type Digest

type Digest int

Digest algorithms

const (
	SHA1 Digest = iota
	SHA256
)

func (Digest) Func

func (d Digest) Func() HashFunc

Obtain the digest hash function

type HashFunc

type HashFunc func() hash.Hash

hash generator

Jump to

Keyboard shortcuts

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