okutil

package
v0.0.0-...-cdc279e Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AesDecrypt

func AesDecrypt(crypted, key []byte, iv []byte, unPaddingFunc func([]byte) []byte) ([]byte, error)

AesDecrypt AesDecrypt

func AesDecryptPkcs5

func AesDecryptPkcs5(crypted []byte, key []byte, iv []byte) ([]byte, error)

AesDecryptPkcs5 解密

func AesDecryptPkcs7

func AesDecryptPkcs7(crypted []byte, key []byte, iv []byte) ([]byte, error)

AesDecryptPkcs7 解密

func AesDecryptPkcs7Base64

func AesDecryptPkcs7Base64(crypted []byte, key []byte, iv []byte) ([]byte, error)

AesDecryptPkcs7Base64 解密

func AesDecryptSimple

func AesDecryptSimple(crypted []byte, key string, iv string) ([]byte, error)

AesDecryptSimple 解密

func AesEncrypt

func AesEncrypt(origData []byte, key []byte, iv []byte, paddingFunc func([]byte, int) []byte) ([]byte, error)

AesEncrypt AesEncrypt

func AesEncryptPkcs5

func AesEncryptPkcs5(origData []byte, key []byte, iv []byte) ([]byte, error)

AesEncryptPkcs5 加密

func AesEncryptPkcs7

func AesEncryptPkcs7(origData []byte, key []byte, iv []byte) ([]byte, error)

AesEncryptPkcs7 加密

func AesEncryptPkcs7Base64

func AesEncryptPkcs7Base64(origData []byte, key []byte, iv []byte) ([]byte, error)

AesEncryptPkcs7Base64

func AesEncryptSimple

func AesEncryptSimple(origData []byte, key string, iv string) ([]byte, error)

AesEncryptSimple 加密

func AnyToDecimal

func AnyToDecimal(num string, n int) int64

AnyToDecimal 任意进制转10进制

func ArrayContains

func ArrayContains(items []string, target string) bool

ArrayContains ArrayContains

func BoolToInt

func BoolToInt(b bool) int

BoolToInt bool值转换为int值

func CopyFile

func CopyFile(dstName, srcName string) (written int64, err error)

CopyFile CopyFile

func DecimalToAny

func DecimalToAny(num int64, n int) string

DecimalToAny 10进制转任意进制

func FormatSlots

func FormatSlots(slots []uint32) string

FormatSlots FormatSlots

func GenUUID

func GenUUID() string

GenUUID 生成uuid

func GetCurve25519Key

func GetCurve25519Key(private, public [32]byte) (Key [32]byte)

GetCurve25519Key GetCurve25519Key

func GetCurve25519KeypPair

func GetCurve25519KeypPair() (Aprivate, Apublic [32]byte)

GetCurve25519KeypPair GetCurve25519KeypPair

func GetExternalIP

func GetExternalIP() (string, error)

GetExternalIP 获取本服务器的外网IP

func GetIntranetIP

func GetIntranetIP() (ips []string, err error)

GetIntranetIP 获取本机IP

func GetRandomString

func GetRandomString(num int) string

GetRandomString 生成随机字符串

func GetSlotNum

func GetSlotNum(slotCount int, v string) uint32

GetSlotNum GetSlotNum

func HashCrc32

func HashCrc32(str string) uint32

HashCrc32 通过字符串获取32位数字

func IntToBool

func IntToBool(b int) bool

IntToBool int值转换为bool

func IsIntranet

func IsIntranet(ipStr string) bool

IsIntranet IsIntranet

func JSONToMap

func JSONToMap(json string) (map[string]interface{}, error)

JSONToMap JsonToMap

func JsonToMap

func JsonToMap(json string) (map[string]interface{}, error)

func MD5

func MD5(str string) string

MD5 加密

func PKCS5Padding

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

PKCS5Padding PKCS5Padding

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

PKCS5UnPadding PKCS5UnPadding

func PKCS7Padding

func PKCS7Padding(ciphertext []byte, blockSize int) []byte

PKCS7Padding PKCS7Padding

func PKCS7UnPadding

func PKCS7UnPadding(origData []byte) []byte

PKCS7UnPadding PKCS7UnPadding

func ReadJSONByByte

func ReadJSONByByte(body []byte, obj interface{}) error

ReadJSONByByte 读取JSON

func ReadJsonByByte

func ReadJsonByByte(body []byte, obj interface{}) error

func RemoveRepeatedElement

func RemoveRepeatedElement(arr []string) (newArr []string)

func SlotsContains

func SlotsContains(b, subslice []byte) bool

SlotsContains SlotsContains

func ToJSON

func ToJSON(obj interface{}) string

ToJSON 将对象转换为JSON

func ToJson

func ToJson(obj interface{}) string

将对象转换为JSON

Types

type FIFO

type FIFO struct {
	// contains filtered or unexported fields
}

func NewFIFO

func NewFIFO(size int) *FIFO

func (*FIFO) Data

func (f *FIFO) Data() []int

func (*FIFO) Len

func (f *FIFO) Len() int

func (*FIFO) Pop

func (f *FIFO) Pop() int

func (*FIFO) Push

func (f *FIFO) Push(val int)

type SlotBitMap

type SlotBitMap struct {
	// contains filtered or unexported fields
}

SlotBitMap SlotBitMap

func NewSlotBitMap

func NewSlotBitMap(slotNum int) *SlotBitMap

NewSlotBitMap NewSlotBitMap

func NewSlotBitMapWithBits

func NewSlotBitMapWithBits(bits []byte) *SlotBitMap

NewSlotBitMapWithBits NewSlotBitMapWithBits

func (*SlotBitMap) CleanSlots

func (s *SlotBitMap) CleanSlots(slots []byte)

CleanSlots CleanSlots

func (*SlotBitMap) ExportSlots

func (s *SlotBitMap) ExportSlots(num int) []byte

ExportSlots ExportSlots

func (*SlotBitMap) GetBits

func (s *SlotBitMap) GetBits() []byte

GetBits GetBits

func (*SlotBitMap) GetSlot

func (s *SlotBitMap) GetSlot(num uint32) bool

GetSlot GetSlot

func (*SlotBitMap) GetVaildSlotNum

func (s *SlotBitMap) GetVaildSlotNum() int

GetVaildSlotNum GetVaildSlotNum

func (*SlotBitMap) GetVaildSlots

func (s *SlotBitMap) GetVaildSlots() []uint32

GetVaildSlots GetVaildSlots

func (*SlotBitMap) MergeSlots

func (s *SlotBitMap) MergeSlots(bs ...[]byte)

MergeSlots MergeSlots

func (*SlotBitMap) Reset

func (s *SlotBitMap) Reset()

Reset Reset

func (*SlotBitMap) SetSlot

func (s *SlotBitMap) SetSlot(num uint32, v bool)

SetSlot SetSlot

func (*SlotBitMap) SetSlotForRange

func (s *SlotBitMap) SetSlotForRange(start, end uint32, v bool)

SetSlotForRange SetSlotForRange [start,end]

type WaitGroupWrapper

type WaitGroupWrapper struct {
	sync.WaitGroup
	Name string
	// contains filtered or unexported fields
}

WaitGroupWrapper waitGroup的包装结构体

func NewWaitGroupWrapper

func NewWaitGroupWrapper(name string) *WaitGroupWrapper

NewWaitGroupWrapper NewWaitGroupWrapper

func (*WaitGroupWrapper) GoroutineCount

func (w *WaitGroupWrapper) GoroutineCount() int64

GoroutineCount 协程数量

func (*WaitGroupWrapper) Wrap

func (w *WaitGroupWrapper) Wrap(cb func())

Wrap Wrap

Jump to

Keyboard shortcuts

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