utils

package
v1.2.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareArgon2Hash

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

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

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

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

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

func DecompressWithGzip(buffer *bytes.Buffer) error

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

func DecompressWithZstd

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

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

DecryptWithAes decrypts bytes based on an Aes compatible hashed key.

func EncryptWithAes

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

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

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

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

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

ReadPayload unencrypts and uncompresses payloads

func RepeatedBytes

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

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

func RepeatedRandomString

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