crypto

package
v0.0.0-...-fcfbbb9 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2019 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AesGCMDecrypt

func AesGCMDecrypt(ciphertext []byte, key []byte) ([]byte, error)

AesGCMDecrypt Decrypt data using AES with the GCM cipher mode (Gives Confidentiality and Authenticity)

func AesGCMEncrypt

func AesGCMEncrypt(plaintext []byte, key []byte) ([]byte, error)

AesGCMEncrypt Encrypt data using AES with the GCM cipher mode (Gives Confidentiality and Authenticity)

func CompareChecksums

func CompareChecksums(first []byte, second []byte) bool

CompareChecksums Compare two check sums. Return true if they are they same

func ComputeMd5Checksum

func ComputeMd5Checksum(data []byte) []byte

ComputeMd5Checksum This returns the data's MD5 checksum.

WARNING: Do NOT Use MD5 in security contexts (defending against intentional manipulations of data from untrusted sources); use only for checking data integrity against machine errors.

func ComputeMd5ChecksumString

func ComputeMd5ChecksumString(data []byte) string

ComputeMd5ChecksumString returns the md5 checksum

func ComputeSha256Checksum

func ComputeSha256Checksum(data []byte) []byte

ComputeSha256Checksum This returns the data's Sha256 checksum

func GenerateAesKey

func GenerateAesKey() []byte

GenerateAesKey will generate a new 32 byte key (Uses OS random source)

func GenerateSalt

func GenerateSalt(length int) []byte

GenerateSalt will generate and return a random salt

func GetHmac256

func GetHmac256(message string, secret string) string

GetHmac256 will generate a HMAC hash encoded to base64

func GetPBKFS2AesKey

func GetPBKFS2AesKey(passphrase string, salt []byte) []byte

GetPBKFS2AesKey will generate a AES key from a passphrase using PBKFS2

func GetRandomInt

func GetRandomInt(min, max int) int

GetRandomInt Get a random number

func GetRandomString

func GetRandomString(length int, charSet string) string

GetRandomString Generate a Random secret

func GetScryptAesKey

func GetScryptAesKey(passphrase string, salt []byte) []byte

GetScryptAesKey will generate a AES key from a passphrase using Scrypt

func GetSha256HashString

func GetSha256HashString(data []byte) string

GetSha256HashString This returns the data's Sha256 checksum as a string representation

func GetSha256HashStringFromStream

func GetSha256HashStringFromStream(stream io.Reader) string

GetSha256HashStringFromStream Return a hash from a stream reader

func ValidateMd5Checksum

func ValidateMd5Checksum(data []byte, sum []byte) bool

ValidateMd5Checksum This returns true if the data matches the provided checksum.

func ValidateSha256Checksum

func ValidateSha256Checksum(data []byte, sum []byte) bool

ValidateSha256Checksum This returns true if the data matches the provided checksum.

Types

This section is empty.

Jump to

Keyboard shortcuts

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