utils

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: May 28, 2020 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareArgon2Hash added in v1.1.0

func CompareArgon2Hash(passphrase, salt string, multiplier uint32, hashedPassword []byte) (bool, error)

CompareArgon2Hash creates an Argon hash and then compares it to a provided hash.

func CompressWithGzip added in v1.1.0

func CompressWithGzip(data []byte, buffer *bytes.Buffer) error

CompressWithGzip uses the standard Gzip Writer to compress data and places data in the supplied buffer.

func CompressWithZstd added in v1.1.0

func CompressWithZstd(data []byte, buffer *bytes.Buffer) error

CompressWithZstd uses an external dependency for Zstd to compress data and places data in the supplied buffer.

func ConvertJSONFileToConfig

func ConvertJSONFileToConfig(fileNamePath string) (*models.RabbitSeasoning, error)

ConvertJSONFileToConfig opens a file.json and converts to RabbitSeasoning.

func ConvertJSONFileToTopologyConfig

func ConvertJSONFileToTopologyConfig(fileNamePath string) (*models.TopologyConfig, error)

ConvertJSONFileToTopologyConfig opens a file.json and converts to Topology.

func CreateLetter

func CreateLetter(letterID uint64, exchangeName string, queueName string, body []byte) *models.Letter

CreateLetter creates a simple letter for publishing.

func CreateMockLetter

func CreateMockLetter(letterID uint64, exchangeName string, queueName string, body []byte) *models.Letter

CreateMockLetter creates a mock letter for publishing.

func CreateMockRandomLetter

func CreateMockRandomLetter(queueName string) *models.Letter

CreateMockRandomLetter creates a mock letter for publishing with random sizes and random Ids.

func CreatePayload added in v1.1.0

func CreatePayload(
	input interface{},
	compression *models.CompressionConfig,
	encryption *models.EncryptionConfig) ([]byte, error)

CreatePayload creates a JSON marshal and optionally compresses and encrypts the bytes.

func CreateTLSConfig

func CreateTLSConfig(pemLocation string, localLocation string) (*tls.Config, error)

CreateTLSConfig creates a x509 TLS Config for use in TLS-based communication.

func CreateWrappedPayload added in v1.1.0

func CreateWrappedPayload(
	input interface{},
	letterID uint64,
	metadata string,
	compression *models.CompressionConfig,
	encryption *models.EncryptionConfig) ([]byte, error)

CreateWrappedPayload wraps your data in a plaintext wrapper called ModdedLetter and performs the selected modifications to data.

func DecompressWithGzip added in v1.1.0

func DecompressWithGzip(buffer *bytes.Buffer) error

DecompressWithGzip uses the standard Gzip Reader to decompress data and places data in the supplied buffer.

func DecompressWithZstd added in v1.1.0

func DecompressWithZstd(buffer *bytes.Buffer) error

DecompressWithZstd uses an external dependency for Zstd to decompress data and places data in the supplied buffer.

func DecryptWithAes added in v1.1.0

func DecryptWithAes(cipherDataWithNonce, hashedKey []byte, nonceSize int) ([]byte, error)

DecryptWithAes decrypts bytes based on an Aes compatible hashed key.

func EncryptWithAes added in v1.1.0

func EncryptWithAes(data, hashedKey []byte, nonceSize int) ([]byte, error)

EncryptWithAes encrypts bytes based on an AES-256 compatible hashed key. If nonceSize is less than 12, the standard, 12, is used.

func GetHashWithArgon added in v1.1.0

func GetHashWithArgon(passphrase, salt string, timeConsideration uint32, multiplier uint32, threads uint8, hashLength uint32) []byte

GetHashWithArgon uses Argon2 version 0x13 to hash a plaintext password with a provided salt string and return hash as bytes.

func GetStringHashWithArgon added in v1.1.0

func GetStringHashWithArgon(passphrase, salt string, timeConsideration uint32, threads uint8, hashLength uint32) string

GetStringHashWithArgon uses Argon2 version 0x13 to hash a plaintext password with a provided salt string and return hash as base64 string.

func RandomBytes

func RandomBytes(size int) []byte

RandomBytes returns a RandomString converted to bytes.

func RandomString

func RandomString(size int) string

RandomString creates a new RandomSource to generate a RandomString unique per nanosecond.

func RandomStringFromSource added in v1.1.0

func RandomStringFromSource(size int, src rand.Source) string

RandomStringFromSource generates a Random string that should always be unique. Example RandSrc.) var src = rand.NewSource(time.Now().UnixNano()) Source: https://stackoverflow.com/questions/22892120/how-to-generate-a-random-string-of-a-fixed-length-in-go

func ReadJSONFileToInterface

func ReadJSONFileToInterface(fileNamePath string) (interface{}, error)

ReadJSONFileToInterface opens a file.json and converts to interface{}.

func ReadPayload added in v1.1.0

func ReadPayload(buffer *bytes.Buffer, compression *models.CompressionConfig, encryption *models.EncryptionConfig) error

ReadPayload unencrypts and uncompresses payloads

func RepeatedBytes added in v1.1.0

func RepeatedBytes(size int, repeat int) []byte

RepeatedBytes generates a RandomString and then repeats it up to size.

func RepeatedRandomString added in v1.1.0

func RepeatedRandomString(size int, repeat int) string

RepeatedRandomString generates a RandomString and then repeats it up to size and repeat count.

Types

This section is empty.

Jump to

Keyboard shortcuts

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