utils

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Length_4 = 4
	Length_8 = 8
)

Variables

This section is empty.

Functions

func AesDecrypt

func AesDecrypt(src, key, iv string) (string, error)

AesDecrypt [in] src : encryped data with base64 encode [out] original data

func AesEncrypt

func AesEncrypt(src, key, iv string) (string, error)

AesEncrypt [in] src : original data [out] encryped data with base64 encode

func Base64Decode

func Base64Decode(in string) []byte

func Base64Encode

func Base64Encode(in []byte) string

func BytesToUint32

func BytesToUint32(buf []byte) uint32

func BytesToUint64

func BytesToUint64(buf []byte) uint64

func Compress

func Compress(data []byte) []byte

func DeCompress

func DeCompress(data []byte) []byte

func FromJson

func FromJson(jsonStr string, v interface{}) error

func GenerateRandomNumInRange added in v0.0.6

func GenerateRandomNumInRange(min, max int) uint32

func GenerateRandomStr added in v0.0.2

func GenerateRandomStr(inseed []byte) string

func GetAppBaseDir

func GetAppBaseDir() string

GetAppBaseDir get the execute file's absolute path

func HexDecode

func HexDecode(in string) []byte

func HexEncode

func HexEncode(in []byte) string

func IsDigit

func IsDigit(str string) bool

func IsPathExisting

func IsPathExisting(path string) bool

func IsPositiveNumber

func IsPositiveNumber(src string) bool

func IsValidEmailAddr

func IsValidEmailAddr(email string) bool

func IsValidStruct added in v0.0.4

func IsValidStruct(dataStruct interface{}) error

using validator library to validate a Struct

func LoadConfigurationFromYamlFile

func LoadConfigurationFromYamlFile(data_dir_from_cli_arg, data_dir_name, cfg_file_name string, out interface{}) (string, error)

@data_dir_from_cli_arg: data dir name come from the command line @dir_name: data dir name @cfg_file_name: configuration file name in `dir_name` directory

func NewRandomUUID added in v0.0.3

func NewRandomUUID() string

func NewUUID added in v0.0.3

func NewUUID() string

generate a new uuid without "-"

func PKCS5Padding

func PKCS5Padding(src []byte, blockSize int) []byte

func PKCS5UnPadding

func PKCS5UnPadding(src []byte) []byte

func ReadJSONFile

func ReadJSONFile(filename string, v interface{}) error

ReadJSONFile reads a JSON format file into v

func RsaDecrypt

func RsaDecrypt(src string, privateKey []byte) (string, error)

convert base64 encoded string to binary as input base64 encoded string

func Sha256

func Sha256(indata []byte) string

func ToJSON

func ToJSON(v interface{}) string

func ToJSONIndent

func ToJSONIndent(v interface{}) string

ToJSONIndent is a helper method that converts the object to human readable format

func Uint32ToBytes

func Uint32ToBytes(dat uint32) []byte

func Uint32ToBytesBuffer

func Uint32ToBytesBuffer(buffer []byte, dat uint32)

func Uint64ToBytes

func Uint64ToBytes(dat uint64) []byte

Types

This section is empty.

Jump to

Keyboard shortcuts

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