cryptoutils

package
v0.0.0-...-841f565 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AES256CBCDecrypt

func AES256CBCDecrypt(cipherText, key string) (string, error)

func AES256CBCEncrypt

func AES256CBCEncrypt(iv []byte, plainText, key, encoding string) (string, error)

func AES256GCMDecrypt

func AES256GCMDecrypt(params AES256GCMParams) (plaintext []byte, err error)

func AES256GCMNounce

func AES256GCMNounce(gcm cipher.AEAD) (nonce []byte, err error)

func CompareHashes

func CompareHashes(expected, recieved hash.Hash) bool

CompareHashes returns true if the provided hashes are equal

func HMAC256Sum

func HMAC256Sum(message, key, format string) (string, error)

HMAC256Sum hashes the input and returns a string in the specified encoding format

func MD5Sum

func MD5Sum(data, format string) (string, error)

MD5Sum hashes the input and returns a string in the specified encoding format

func PKCS7Pad

func PKCS7Pad(data []byte, blockSize int) ([]byte, error)

PKCS7Pad add pkcs7 padding

func PKCS7Strip

func PKCS7Strip(data []byte, blockSize int) ([]byte, error)

PKCS7Strip remove pkcs7 padding

func RandomIV

func RandomIV(length int) ([]byte, error)

RandomIV generates a random initialization vector of length n

func SHA1Sum

func SHA1Sum(data, format string) (string, error)

SHA1Sum hashes the input and returns a string in the specified encoding format

func SHA256Sum

func SHA256Sum(data, format string) (string, error)

SHA256Sum hashes the input and returns a string in the specified encoding format

Types

type AES256CBCCrypter

type AES256CBCCrypter struct {
	Key                 []byte
	IV                  []byte
	BlockPaddingEnabled bool
}

AES256CBCCrypter hashes the input and returns a string in the specified encoding format

func NewAES256CBCCrypter

func NewAES256CBCCrypter(iv, key []byte, disablePadding bool) *AES256CBCCrypter

NewAES256CBCCrypter returns an AES256CBCCrypter

func (*AES256CBCCrypter) Decrypt

func (crypter *AES256CBCCrypter) Decrypt(cipherText []byte) ([]byte, error)

Decrypt decrypts cip

func (*AES256CBCCrypter) Encrypt

func (crypter *AES256CBCCrypter) Encrypt(plainText []byte) ([]byte, error)

Encrypt accepts plainText bytes and returns encrypts them using aes-256-cbc returning cipherText bytes

type AES256GCMParams

type AES256GCMParams struct {
	Key            []byte
	Nonce          []byte
	Ciphertext     []byte
	Plaintext      []byte
	AdditionalData []byte
}

func AES256GCMEncrypt

func AES256GCMEncrypt(params AES256GCMParams) (result AES256GCMParams, err error)

type HMACOptions

type HMACOptions struct {
	Message    string
	Key        string
	KeyFormat  string
	HashFormat string
}

HMACOptions ...

Jump to

Keyboard shortcuts

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