hmac

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: BSD-3-Clause Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// CipherName is the name of the cipher as registered on symmecrypt
	CipherName = "hmac"

	// KeyLen is the number of raw bytes for a key
	KeyLen = 32
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

type Key []byte

Key is a simple key which uses plain data + HMAC-sha512 for authentication

func (Key) Decrypt

func (k Key) Decrypt(data []byte, extra ...[]byte) ([]byte, error)

Decrypt checks the appended base64 HMAC-sha512 using the plaintext part + extra data, and returns the plaintext only.

func (Key) DecryptMarshal

func (k Key) DecryptMarshal(s string, v interface{}, extra ...[]byte) error

DecryptMarshal takes as parameter an opaque base64 encoded string, checks the HMAC-sha512 appended to the JSON representation, and unmarshals it into the target.

func (Key) Encrypt

func (k Key) Encrypt(plain []byte, extra ...[]byte) ([]byte, error)

Encrypt appends a base64 HMAC-sha512 (with fully printable characters) calculated from the plaintext + extra data, to the plaintext.

func (Key) EncryptMarshal

func (k Key) EncryptMarshal(v interface{}, extra ...[]byte) (string, error)

EncryptMarshal appends a HMAC-sha512 to the JSON representation of the object, and returns an opaque base64 encoded string.

func (Key) String

func (k Key) String() (string, error)

String returns an hex encoded representation of the key

func (Key) Wait

func (k Key) Wait()

Wait is a no-op

Jump to

Keyboard shortcuts

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