util

package
v0.0.0-...-36df34d Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AES_KEY_LENGTH     = 32
	DEFAULT_KEY_LENGTH = AES_KEY_LENGTH
	IV_LENGTH          = 12 // Pretty standard size (bytes).
)
View Source
const (
	RANDOM_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
)

Variables

This section is empty.

Functions

func CeilInt

func CeilInt(x float32) int

func CeilInt64

func CeilInt64(x float64) int64

func CeilUint64

func CeilUint64(x float64) uint64

func Decrypt

func Decrypt(key []byte, iv []byte, ciphertext []byte) ([]byte, error)

func Encrypt

func Encrypt(key []byte, iv []byte, cleartext []byte) ([]byte, error)

One-off encryption and decryption. This is not meant for huge chunks of data.

func GenAESKey

func GenAESKey() []byte

func GenIV

func GenIV() []byte

func GenKey

func GenKey(length int) []byte

Generate a key (random bytes) of the given length (in bytes).

func IncrementBytes

func IncrementBytes(bytes []byte)

"Increment" the byte silce by going through each byte (big endian) and incremnt it. If the byte does not roll over to zero, then stop there.

func IncrementBytesByCount

func IncrementBytesByCount(bytes []byte, count int)

func MaxInt

func MaxInt(a int, b int) int

func MaxInt64

func MaxInt64(a int64, b int64) int64

func MinInt

func MinInt(a int, b int) int

func MinInt64

func MinInt64(a int64, b int64) int64

func RandomBytes

func RandomBytes(length int) []byte

func RandomString

func RandomString(length int) string

func SHA256Hex

func SHA256Hex(val string) string

Get the SHA2-256 string.

func ScanInt

func ScanInt(scanner *bufio.Scanner) (int, error)

Will Scan() the scanner once and read the contents as a string.

func SliceHasString

func SliceHasString(haystack []string, needle string) bool

Uses standard n search and equality.

func Weakhash

func Weakhash(username string, password string) string

Generate a password hash the same way that clients are expected to.

Types

type ReadSeekCloser

type ReadSeekCloser interface {
	io.Closer
	io.Reader
	io.Seeker
}

Jump to

Keyboard shortcuts

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