u

package module
v1.7.26 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 46 Imported by: 100

README

utility

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AESCBC = &AESCipher{useGCM: false}
View Source
var AESGCM = &AESCipher{useGCM: true}
View Source
var DefaultIdMaker = NewIdMaker(nil)
View Source
var DefaultIntEncoder, _ = NewIntEncoder("9ukH1grX75TQS6LzpFAjIivsdZoO0mc8NBwnyYDhtMWEC2V3KaGxfJRPqe4lbU", 62)
View Source
var ECDSACBC = &ECDSAAlgorithm{useGCM: false, hash: crypto.SHA256}
View Source
var ECDSAGCM = &ECDSAAlgorithm{useGCM: true, hash: crypto.SHA256}
View Source
var ED25519 = &Ed25519Algorithm{}
View Source
var GlobalRand1 = &Rand{}
View Source
var GlobalRand2 = &Rand{isPCG: true}
View Source
var OrderedIntEncoder, _ = NewIntEncoder("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 62)
View Source
var RSA = &RSAAlgorithm{isPSS: true, isOAEP: true}
View Source
var RSAPKCS1v15 = &RSAAlgorithm{isPSS: false, isOAEP: false}

Deprecated: RSAPKCS1v15 is not recommended. Please use RSA instead.

View Source
var X25519CBC = &X25519Algorithm{useGCM: false, hash: crypto.SHA256}
View Source
var X25519GCM = &X25519Algorithm{useGCM: true, hash: crypto.SHA256}

Functions

func AddFileToMemory added in v1.7.4

func AddFileToMemory(memFile MemFile)

func AddTime added in v1.7.14

func AddTime(timeStr string, timeValue interface{}) time.Time

func AppendInt

func AppendInt(buf []byte, u uint64) []byte

func AppendUniqueString added in v0.1.17

func AppendUniqueString(to []string, from string) []string

func AppendUniqueStrings added in v0.1.17

func AppendUniqueStrings(to []string, from []string) []string

func Archive added in v1.7.24

func Archive(srcPath, destFile string) error

Archive 将目录或文件打包成 zip 或 tar.gz

func BBlack

func BBlack(s interface{}, attribs ...AttribCode) string

func BBlue

func BBlue(s interface{}, attribs ...AttribCode) string

func BCyan

func BCyan(s interface{}, attribs ...AttribCode) string

func BGreen

func BGreen(s interface{}, attribs ...AttribCode) string

func BMagenta

func BMagenta(s interface{}, attribs ...AttribCode) string

func BRed

func BRed(s interface{}, attribs ...AttribCode) string

func BWhite

func BWhite(s interface{}, attribs ...AttribCode) string

func BYellow

func BYellow(s interface{}, attribs ...AttribCode) string

func Base64 added in v0.5.40

func Base64(data []byte) []byte

func Base64String added in v0.5.40

func Base64String(data []byte) string

func Black

func Black(s interface{}, attribs ...AttribCode) string

func Blue

func Blue(s interface{}, attribs ...AttribCode) string

func Bool

func Bool(value interface{}) bool

func BoolPtr added in v1.7.20

func BoolPtr(value bool) *bool

func Bytes

func Bytes(value interface{}) []byte

func CheckPath added in v0.0.8

func CheckPath(filename string)

func Color

func Color(s interface{}, textColor TextColor, bgColor BgColor, attribs ...AttribCode) string

func Compress added in v1.7.24

func Compress(data []byte, cType string) ([]byte, error)

func Convert added in v0.1.9

func Convert(from, to interface{})

func CopyFile added in v0.5.40

func CopyFile(from, to string) error

func CopyToFile added in v0.5.40

func CopyToFile(from io.Reader, to string) error

func Cyan

func Cyan(s interface{}, attribs ...AttribCode) string

func DecodeInt

func DecodeInt(buf []byte) uint64

func Decompress added in v1.7.24

func Decompress(data []byte, cType string) ([]byte, error)

func DecryptChaCha20 added in v1.7.25

func DecryptChaCha20(cipher []byte, key []byte, salt []byte) []byte

func Dim added in v0.0.4

func Dim(s interface{}) string

func DisableCoreDump added in v1.7.25

func DisableCoreDump() error

func Duration added in v0.1.17

func Duration(value string) time.Duration

func EncodeInt

func EncodeInt(u uint64) []byte

func EncryptChaCha20 added in v1.7.25

func EncryptChaCha20(raw []byte, key []byte, salt []byte) []byte

func ExchangeInt added in v1.7.14

func ExchangeInt(buf []byte) []byte

func Extract added in v1.7.24

func Extract(srcFile, destDir string, stripRoot bool) error

Extract 自动识别格式并解压 (支持 .zip, .tar.gz, .tgz, .tar, .gz, .bz2)

func FileExists added in v0.0.8

func FileExists(filename string) bool

func FillInt added in v0.1.17

func FillInt(buf []byte, length int) []byte

func FinalSet added in v1.7.1

func FinalSet(from, to reflect.Value)

func FinalType added in v0.1.9

func FinalType(v reflect.Value) reflect.Type

func FinalValue added in v0.1.9

func FinalValue(v reflect.Value) reflect.Value

func FixJsonBytes added in v0.5.40

func FixJsonBytes(b []byte) []byte

修复Golang中Json默认处理HTML转义 < > & 的问题

func FixNilValue added in v0.1.9

func FixNilValue(v reflect.Value)

func FixPath added in v0.1.17

func FixPath(path string) string

func FixPtr added in v0.5.33

func FixPtr(value interface{}) interface{}

func FixUpperCase

func FixUpperCase(data []byte, excludesKeys []string)

func FixedJson added in v0.5.40

func FixedJson(value interface{}) string

func FixedJsonP added in v0.5.40

func FixedJsonP(value interface{}) string

func Float

func Float(value interface{}) float32

func Float32Ptr added in v1.7.20

func Float32Ptr(value float32) *float32

func Float64

func Float64(value interface{}) float64

func Float64Ptr added in v1.7.20

func Float64Ptr(value float64) *float64

func Floats

func Floats(value interface{}) []float64

func FormatTime added in v1.7.14

func FormatTime(layout string, timeValue interface{}) string

func GenerateECDSAKeyPair added in v1.7.25

func GenerateECDSAKeyPair(bitSize int) ([]byte, []byte, error)

func GenerateEd25519KeyPair added in v1.7.25

func GenerateEd25519KeyPair() ([]byte, []byte, error)

func GenerateRSAKeyPair added in v1.7.25

func GenerateRSAKeyPair(bitSize int) ([]byte, []byte, error)

func GenerateX25519KeyPair added in v1.7.25

func GenerateX25519KeyPair() ([]byte, []byte, error)

func GetAbsFilename added in v1.7.5

func GetAbsFilename(filename string) string

func GetLowerName added in v0.1.9

func GetLowerName(s string) string

func GetUpperName added in v0.1.9

func GetUpperName(s string) string

func Green

func Green(s interface{}, attribs ...AttribCode) string

func Gunzip added in v1.7.4

func Gunzip(data []byte) ([]byte, error)

func GunzipN added in v1.7.4

func GunzipN(data []byte) []byte

func Gzip added in v1.7.4

func Gzip(data []byte) ([]byte, error)

你要求的原有接口保持不变

func GzipN added in v1.7.4

func GzipN(data []byte) []byte

func HashInt added in v1.7.14

func HashInt(buf []byte) []byte

func Hex added in v1.7.22

func Hex(data []byte) []byte

func HexString added in v1.7.25

func HexString(data []byte) string

func HmacMD5 added in v1.7.22

func HmacMD5(key []byte, data ...[]byte) []byte

func HmacSha1 added in v1.7.22

func HmacSha1(key []byte, data ...[]byte) []byte

func HmacSha256 added in v1.7.22

func HmacSha256(key []byte, data ...[]byte) []byte

func HmacSha512 added in v1.7.22

func HmacSha512(key []byte, data ...[]byte) []byte

func If

func If(i bool, a, b interface{}) interface{}

func In added in v0.1.8

func In(arr []interface{}, s interface{}) bool

func Int

func Int(value interface{}) int

func Int64

func Int64(value interface{}) int64

func Int64Ptr added in v1.7.20

func Int64Ptr(value int64) *int64

func IntPtr added in v1.7.20

func IntPtr(value int) *int

func IntSlicePtr added in v1.7.20

func IntSlicePtr(value []int) *[]int

func Ints

func Ints(value interface{}) []int64

func Italic added in v0.0.4

func Italic(s interface{}) string

func JoinArgs added in v0.5.30

func JoinArgs(arr []string, sep string) string

func Json added in v0.1.6

func Json(value interface{}) string

func JsonBytes added in v0.5.40

func JsonBytes(value interface{}) []byte

func JsonBytesP added in v0.5.40

func JsonBytesP(value interface{}) []byte

func JsonP added in v0.1.6

func JsonP(value interface{}) string

func Load added in v0.0.8

func Load(filename string, to any) error

func LoadFileToMemory added in v1.7.4

func LoadFileToMemory(filename string)

func LoadFileToMemoryWithCompress added in v1.7.4

func LoadFileToMemoryWithCompress(filename string)

func LoadFilesToMemoryFromB64 added in v1.7.4

func LoadFilesToMemoryFromB64(b64File *MemFileB64)

func LoadFilesToMemoryFromB64KeepGzip added in v1.7.4

func LoadFilesToMemoryFromB64KeepGzip(b64File *MemFileB64)

func LoadFilesToMemoryFromJson added in v1.7.4

func LoadFilesToMemoryFromJson(jsonFiles string)

func LoadJson added in v0.1.13

func LoadJson(filename string, to any) error

func LoadX added in v0.5.30

func LoadX(filename string, to any) error

func LoadYaml added in v0.1.13

func LoadYaml(filename string, to any) error

func MD5 added in v0.1.17

func MD5(data ...[]byte) []byte

func MD5Base64 added in v0.1.17

func MD5Base64(data string) string

func MD5String added in v0.1.17

func MD5String(data string) string

func Magenta

func Magenta(s interface{}, attribs ...AttribCode) string

func MakeBoolMap added in v1.7.20

func MakeBoolMap(str string) map[string]bool

func MakeExcludeUpperKeys added in v0.5.50

func MakeExcludeUpperKeys(data interface{}, prefix string) []string

func MakeId added in v1.7.26

func MakeId(size int) string

func MakeSafeToken added in v1.7.25

func MakeSafeToken(size int) []byte

func MakeToken added in v0.5.43

func MakeToken(size int) []byte

func MapPtr added in v1.7.20

func MapPtr(value map[string]interface{}) *map[string]interface{}

func ParseInt added in v0.1.9

func ParseInt(s string) int64

func ParseTime added in v1.7.14

func ParseTime(v interface{}) time.Time

func ParseUint added in v0.1.9

func ParseUint(s string) uint64

func ReadFile added in v0.0.8

func ReadFile(filename string) (string, error)

func ReadFileBytes added in v0.5.30

func ReadFileBytes(filename string) ([]byte, error)

func ReadFileBytesN added in v1.7.4

func ReadFileBytesN(filename string) []byte

func ReadFileLines added in v0.1.15

func ReadFileLines(filename string) ([]string, error)

func ReadFileLinesN added in v1.7.4

func ReadFileLinesN(filename string) []string

func ReadFileN added in v1.7.4

func ReadFileN(filename string) string

func RealValue added in v0.1.9

func RealValue(v reflect.Value) reflect.Value

func Red

func Red(s interface{}, attribs ...AttribCode) string

func RunCommand added in v0.0.8

func RunCommand(command string, args ...string) ([]string, error)

func SafeLoadFileToMemory added in v1.7.25

func SafeLoadFileToMemory(filename string)

func SafeLoadFileToMemoryWithCompress added in v1.7.25

func SafeLoadFileToMemoryWithCompress(filename string)

func Save added in v0.0.8

func Save(filename string, data any) error

func SaveJson added in v0.1.13

func SaveJson(filename string, data any) error

func SaveJsonP added in v0.1.17

func SaveJsonP(filename string, data any) error

func SaveYaml added in v0.1.13

func SaveYaml(filename string, data any) error

func SetSafeBufObfuscator added in v1.7.25

func SetSafeBufObfuscator(encrypt func([]byte) ([]byte, []byte), decrypt func([]byte, []byte) []byte)

func SetValue added in v0.1.17

func SetValue(to, from reflect.Value)

func Sha1 added in v0.1.17

func Sha1(data ...[]byte) []byte

func Sha1Base64 added in v0.1.17

func Sha1Base64(data string) string

func Sha1String added in v0.1.17

func Sha1String(data string) string

func Sha256 added in v0.1.17

func Sha256(data ...[]byte) []byte

func Sha256Base64 added in v0.1.17

func Sha256Base64(data string) string

func Sha256String added in v0.1.17

func Sha256String(data string) string

func Sha512 added in v0.1.17

func Sha512(data ...[]byte) []byte

func Sha512Base64 added in v0.1.17

func Sha512Base64(data string) string

func Sha512String added in v0.1.17

func Sha512String(data string) string

func SplitArgs added in v0.5.30

func SplitArgs(s string) []string

func SplitTrim added in v0.1.12

func SplitTrim(s, sep string) []string

func SplitTrimN added in v1.7.14

func SplitTrimN(s, sep string, n int) []string

func SplitWithoutNone added in v0.1.17

func SplitWithoutNone(s, sep string) []string

func SplitWithoutNoneN added in v1.7.14

func SplitWithoutNoneN(s, sep string, n int) []string

func String

func String(value interface{}) string

func StringFromValue added in v1.7.7

func StringFromValue(v reflect.Value) string

func StringIf

func StringIf(i bool, a, b string) string

func StringIn added in v0.1.8

func StringIn(arr []string, s string) bool

func StringP added in v0.5.50

func StringP(value interface{}) string

func StringPtr added in v1.7.20

func StringPtr(value string) *string

func StringSlicePtr added in v1.7.20

func StringSlicePtr(value []string) *[]string

func Strings

func Strings(value interface{}) []string

func Switch

func Switch(i uint, args ...interface{}) interface{}

func ToInterfaceArray added in v0.1.17

func ToInterfaceArray(in interface{}) []interface{}

func UInt64Ptr added in v1.7.20

func UInt64Ptr(value uint64) *uint64

func UIntPtr added in v1.7.20

func UIntPtr(value uint) *uint

func Uint added in v0.1.9

func Uint(value interface{}) uint

func Uint64 added in v0.1.9

func Uint64(value interface{}) uint64

func UnBase64 added in v0.5.40

func UnBase64(data []byte) ([]byte, error)

func UnBase64String added in v0.5.40

func UnBase64String(data string) ([]byte, error)

func UnHex added in v1.7.25

func UnHex(data []byte) ([]byte, error)

func UnHexString added in v1.7.25

func UnHexString(data string) ([]byte, error)

func UnJson added in v0.5.40

func UnJson(str string, value interface{}) interface{}

func UnJsonArr added in v0.5.40

func UnJsonArr(str string) []interface{}

func UnJsonBytes added in v0.5.40

func UnJsonBytes(data []byte, value interface{}) interface{}

func UnJsonMap added in v0.5.40

func UnJsonMap(str string) map[string]interface{}

func UnUrlBase64 added in v0.5.40

func UnUrlBase64(data []byte) ([]byte, error)

func UnUrlBase64String added in v0.5.40

func UnUrlBase64String(data string) ([]byte, error)

func UnYaml added in v0.5.40

func UnYaml(data string, value interface{}) interface{}

func UnYamlArr added in v0.5.40

func UnYamlArr(data string) []interface{}

func UnYamlMap added in v0.5.40

func UnYamlMap(data string) map[string]interface{}

func Unzip added in v1.7.24

func Unzip(data []byte) ([]byte, error)

func UnzipN added in v1.7.24

func UnzipN(data []byte) []byte

func UrlBase64 added in v0.5.40

func UrlBase64(data []byte) []byte

func UrlBase64String added in v0.5.40

func UrlBase64String(data []byte) string

func ValueToString added in v0.1.10

func ValueToString(v reflect.Value) string

func White

func White(s interface{}, attribs ...AttribCode) string

func WriteFile added in v0.1.15

func WriteFile(filename string, content string) error

func WriteFileBytes added in v0.5.30

func WriteFileBytes(filename string, content []byte) error

func Yaml added in v0.5.40

func Yaml(value interface{}) string

func Yellow

func Yellow(s interface{}, attribs ...AttribCode) string

func ZeroMemory added in v1.7.25

func ZeroMemory(buf []byte)

func Zip added in v1.7.24

func Zip(data []byte) ([]byte, error)

func ZipN added in v1.7.24

func ZipN(data []byte) []byte

Types

type AESCipher added in v1.7.25

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

func (*AESCipher) Decrypt added in v1.7.25

func (_this *AESCipher) Decrypt(data []byte, key []byte, iv []byte) ([]byte, error)

func (*AESCipher) Encrypt added in v1.7.25

func (_this *AESCipher) Encrypt(data []byte, key []byte, iv []byte) ([]byte, error)

type Asymmetric added in v1.7.25

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

func NewAsymmetric added in v1.7.25

func NewAsymmetric(algorithm AsymmetricAlgorithm, safePrivateKeyBuf, safePublicKeyBuf *SafeBuf) (*Asymmetric, error)

func NewAsymmetricAndEraseKey added in v1.7.25

func NewAsymmetricAndEraseKey(algorithm AsymmetricAlgorithm, privateKey, publicKey []byte) (*Asymmetric, error)

func NewAsymmetricWithoutEraseKey added in v1.7.25

func NewAsymmetricWithoutEraseKey(algorithm AsymmetricAlgorithm, privateKey, publicKey []byte, fastModeButIsNotSecure bool) (*Asymmetric, error)

func NewECDSA added in v1.7.25

func NewECDSA(safePrivateKeyBuf, safePublicKeyBuf *SafeBuf) (*Asymmetric, error)

func NewECDSAWithOutEraseKey added in v1.7.25

func NewECDSAWithOutEraseKey(safePrivateKeyBuf, safePublicKeyBuf []byte) (*Asymmetric, error)

func NewECDSAndEraseKey added in v1.7.25

func NewECDSAndEraseKey(safePrivateKeyBuf, safePublicKeyBuf []byte) (*Asymmetric, error)

func NewED25519 added in v1.7.25

func NewED25519(safePrivateKeyBuf, safePublicKeyBuf *SafeBuf) (*Asymmetric, error)

func NewED25519AndEraseKey added in v1.7.25

func NewED25519AndEraseKey(safePrivateKeyBuf, safePublicKeyBuf []byte) (*Asymmetric, error)

func NewED25519WithOutEraseKey added in v1.7.25

func NewED25519WithOutEraseKey(safePrivateKeyBuf, safePublicKeyBuf []byte) (*Asymmetric, error)

func NewRSA added in v1.7.25

func NewRSA(safePrivateKeyBuf, safePublicKeyBuf *SafeBuf) (*Asymmetric, error)

func NewRSAWithOutEraseKey added in v1.7.25

func NewRSAWithOutEraseKey(safePrivateKeyBuf, safePublicKeyBuf []byte) (*Asymmetric, error)

func NewRSAndEraseKey added in v1.7.25

func NewRSAndEraseKey(safePrivateKeyBuf, safePublicKeyBuf []byte) (*Asymmetric, error)

func NewX25519 added in v1.7.25

func NewX25519(safePrivateKeyBuf, safePublicKeyBuf *SafeBuf) (*Asymmetric, error)

func NewX25519AndEraseKey added in v1.7.25

func NewX25519AndEraseKey(safePrivateKeyBuf, safePublicKeyBuf []byte) (*Asymmetric, error)

func NewX25519WithOutEraseKey added in v1.7.25

func NewX25519WithOutEraseKey(safePrivateKeyBuf, safePublicKeyBuf []byte) (*Asymmetric, error)

func (*Asymmetric) Close added in v1.7.25

func (_this *Asymmetric) Close()

func (*Asymmetric) Decrypt added in v1.7.25

func (_this *Asymmetric) Decrypt(data []byte) ([]byte, error)

func (*Asymmetric) Encrypt added in v1.7.25

func (_this *Asymmetric) Encrypt(data []byte) ([]byte, error)

func (*Asymmetric) Sign added in v1.7.25

func (_this *Asymmetric) Sign(data []byte) ([]byte, error)

func (*Asymmetric) Verify added in v1.7.25

func (_this *Asymmetric) Verify(data []byte, signature []byte) (bool, error)

type AsymmetricAlgorithm added in v1.7.25

type AsymmetricAlgorithm interface {
	ParsePrivateKey(der []byte) (any, error)
	ParsePublicKey(der []byte) (any, error)
	Sign(privateKey any, data []byte, hash ...crypto.Hash) ([]byte, error)
	Verify(publicKey any, data []byte, signature []byte, hash ...crypto.Hash) (bool, error)
}

type AsymmetricCipherAlgorithm added in v1.7.25

type AsymmetricCipherAlgorithm interface {
	Encrypt(publicKey any, data []byte) ([]byte, error)
	Decrypt(privateKey any, data []byte) ([]byte, error)
}

type AttribCode

type AttribCode int
const (
	AttrNone AttribCode = iota
	AttrBold
	AttrDim
	AttrItalic
	AttrUnderline
	AttrBlink
	AttrFastBlink
	AttrReverse
	AttrHidden
	AttrCrossedOut
)

type BgColor

type BgColor int
const (
	BgBlack BgColor = iota + 40
	BgRed
	BgGreen
	BgYellow
	BgBlue
	BgMagenta
	BgCyan
	BgWhite
	BgNone BgColor = 0
)

type ECDSAAlgorithm added in v1.7.25

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

func NewECDSAAlgorithm added in v1.7.25

func NewECDSAAlgorithm(useGCM bool, hash crypto.Hash, kdfInfo, kdfSalt []byte) *ECDSAAlgorithm

func (*ECDSAAlgorithm) Decrypt added in v1.7.25

func (e *ECDSAAlgorithm) Decrypt(privateKeyObj any, data []byte) ([]byte, error)

func (*ECDSAAlgorithm) Encrypt added in v1.7.25

func (e *ECDSAAlgorithm) Encrypt(publicKeyObj any, data []byte) ([]byte, error)

func (*ECDSAAlgorithm) ParsePrivateKey added in v1.7.25

func (e *ECDSAAlgorithm) ParsePrivateKey(der []byte) (any, error)

func (*ECDSAAlgorithm) ParsePublicKey added in v1.7.25

func (e *ECDSAAlgorithm) ParsePublicKey(der []byte) (any, error)

func (*ECDSAAlgorithm) Sign added in v1.7.25

func (e *ECDSAAlgorithm) Sign(privateKeyObj any, data []byte, hash ...crypto.Hash) ([]byte, error)

func (*ECDSAAlgorithm) Verify added in v1.7.25

func (e *ECDSAAlgorithm) Verify(publicKeyObj any, data []byte, signature []byte, hash ...crypto.Hash) (bool, error)

type Ed25519Algorithm added in v1.7.25

type Ed25519Algorithm struct{}

func (*Ed25519Algorithm) ParsePrivateKey added in v1.7.25

func (e *Ed25519Algorithm) ParsePrivateKey(der []byte) (any, error)

func (*Ed25519Algorithm) ParsePublicKey added in v1.7.25

func (e *Ed25519Algorithm) ParsePublicKey(der []byte) (any, error)

func (*Ed25519Algorithm) Sign added in v1.7.25

func (e *Ed25519Algorithm) Sign(privateKeyObj any, data []byte, hash ...crypto.Hash) ([]byte, error)

func (*Ed25519Algorithm) Verify added in v1.7.25

func (e *Ed25519Algorithm) Verify(publicKeyObj any, data []byte, signature []byte, hash ...crypto.Hash) (bool, error)

type FileInfo added in v1.7.4

type FileInfo struct {
	Name     string
	FullName string
	IsDir    bool
	Size     int64
	ModTime  time.Time
}

func GetFileInfo added in v1.7.5

func GetFileInfo(filename string) *FileInfo

func ReadDir added in v1.7.4

func ReadDir(filename string) ([]FileInfo, error)

func ReadDirN added in v1.7.4

func ReadDirN(filename string) []FileInfo

type IdMaker added in v1.7.26

type IdMaker struct {
	Incr func(sec uint64) uint64
	// contains filtered or unexported fields
}

func NewIdMaker added in v1.7.26

func NewIdMaker(incr func(sec uint64) uint64) *IdMaker

func (*IdMaker) Get added in v1.7.26

func (im *IdMaker) Get(size int) string

func (*IdMaker) GetForMysql added in v1.7.26

func (im *IdMaker) GetForMysql(size int) string

func (*IdMaker) GetForPostgreSQL added in v1.7.26

func (im *IdMaker) GetForPostgreSQL(size int) string

type IntEncoder added in v1.7.25

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

func NewIntEncoder

func NewIntEncoder(digits string, radix uint8) (*IntEncoder, error)

func (*IntEncoder) AppendInt added in v1.7.25

func (enc *IntEncoder) AppendInt(buf []byte, u uint64) []byte

func (*IntEncoder) DecodeInt added in v1.7.25

func (enc *IntEncoder) DecodeInt(buf []byte) uint64

func (*IntEncoder) EncodeInt added in v1.7.25

func (enc *IntEncoder) EncodeInt(u uint64) []byte

func (*IntEncoder) FillInt added in v1.7.25

func (enc *IntEncoder) FillInt(buf []byte, length int) []byte

func (*IntEncoder) HashInt added in v1.7.25

func (enc *IntEncoder) HashInt(buf []byte) []byte

type MemFile added in v1.7.4

type MemFile struct {
	Name string

	ModTime    time.Time
	IsDir      bool
	Compressed bool
	Size       int64
	Data       []byte
	SafeData   *SafeBuf
	// contains filtered or unexported fields
}

func ReadDirFromMemory added in v1.7.4

func ReadDirFromMemory(name string) []MemFile

func ReadFileFromMemory added in v1.7.4

func ReadFileFromMemory(name string) *MemFile

func (*MemFile) GetData added in v1.7.4

func (mf *MemFile) GetData() []byte

func (*MemFile) GetSafeData added in v1.7.25

func (mf *MemFile) GetSafeData() *SecretPlaintext

type MemFileB64 added in v1.7.4

type MemFileB64 struct {
	Name       string
	ModTime    time.Time
	IsDir      bool
	DataB64    []byte
	Compressed bool
	Size       int64
	Children   []MemFileB64
}

func LoadFileToB64 added in v1.7.4

func LoadFileToB64(filename string) *MemFileB64

type RSAAlgorithm added in v1.7.25

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

func (*RSAAlgorithm) Decrypt added in v1.7.25

func (r *RSAAlgorithm) Decrypt(privateKeyObj any, data []byte) ([]byte, error)

func (*RSAAlgorithm) Encrypt added in v1.7.25

func (r *RSAAlgorithm) Encrypt(publicKeyObj any, data []byte) ([]byte, error)

func (*RSAAlgorithm) ParsePrivateKey added in v1.7.25

func (r *RSAAlgorithm) ParsePrivateKey(der []byte) (any, error)

func (*RSAAlgorithm) ParsePublicKey added in v1.7.25

func (r *RSAAlgorithm) ParsePublicKey(der []byte) (any, error)

func (*RSAAlgorithm) Sign added in v1.7.25

func (r *RSAAlgorithm) Sign(privateKeyObj any, data []byte, hash ...crypto.Hash) ([]byte, error)

func (*RSAAlgorithm) Verify added in v1.7.25

func (r *RSAAlgorithm) Verify(publicKeyObj any, data []byte, signature []byte, hash ...crypto.Hash) (bool, error)

type Rand added in v1.7.8

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

func (*Rand) Float32 added in v1.7.8

func (r *Rand) Float32() float32

func (*Rand) Float64 added in v1.7.8

func (r *Rand) Float64() float64

func (*Rand) Int added in v1.7.8

func (r *Rand) Int() int

func (*Rand) Int31n deprecated added in v1.7.8

func (r *Rand) Int31n(n int32) int32

Deprecated: use IntN instead

func (*Rand) Int32 added in v1.7.25

func (r *Rand) Int32() int32

func (*Rand) Int32N added in v1.7.25

func (r *Rand) Int32N(n int32) int32

func (*Rand) Int63n deprecated added in v1.7.8

func (r *Rand) Int63n(n int64) int64

Deprecated: use Int64N instead

func (*Rand) Int64 added in v1.7.25

func (r *Rand) Int64() int64

func (*Rand) Int64N added in v1.7.25

func (r *Rand) Int64N(n int64) int64

func (*Rand) IntN added in v1.7.25

func (r *Rand) IntN(n int) int

func (*Rand) Intn deprecated added in v1.7.8

func (r *Rand) Intn(n int) int

Deprecated: use IntN instead

func (*Rand) Perm added in v1.7.8

func (r *Rand) Perm(n int) []int

func (*Rand) Shuffle added in v1.7.8

func (r *Rand) Shuffle(n int, swap func(i, j int))

func (*Rand) Uint32 added in v1.7.8

func (r *Rand) Uint32() uint32

func (*Rand) Uint32N added in v1.7.25

func (r *Rand) Uint32N(n uint32) uint32

func (*Rand) Uint64 added in v1.7.8

func (r *Rand) Uint64() uint64

func (*Rand) Uint64N added in v1.7.25

func (r *Rand) Uint64N(n uint64) uint64

func (*Rand) UintN added in v1.7.25

func (r *Rand) UintN(n uint) uint

type SafeBuf added in v1.7.25

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

func MakeSafeBuf added in v1.7.25

func MakeSafeBuf(cipher, salt []byte) *SafeBuf

func NewSafeBuf added in v1.7.25

func NewSafeBuf(raw []byte) *SafeBuf

func (*SafeBuf) Close added in v1.7.25

func (sb *SafeBuf) Close()

func (*SafeBuf) Open added in v1.7.25

func (sb *SafeBuf) Open() *SecretPlaintext

type SecretPlaintext added in v1.7.25

type SecretPlaintext struct {
	Data []byte
}

func NewSafeString added in v1.7.25

func NewSafeString(raw []byte) (*SecretPlaintext, string)

func (*SecretPlaintext) Close added in v1.7.25

func (sp *SecretPlaintext) Close()

func (*SecretPlaintext) String added in v1.7.25

func (sp *SecretPlaintext) String() string

type StructInfo added in v0.5.43

type StructInfo struct {
	Fields       []reflect.StructField
	Values       map[string]reflect.Value
	Methods      []reflect.Method
	MethodValues map[string]reflect.Value
}

func FlatStruct added in v0.5.43

func FlatStruct(data interface{}) *StructInfo

func FlatStructWithUnexported added in v0.5.43

func FlatStructWithUnexported(data interface{}) *StructInfo

type Symmetric added in v1.7.25

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

func NewAESCBC added in v1.7.25

func NewAESCBC(safeKeyBuf, safeIvBuf *SafeBuf) (*Symmetric, error)

func NewAESCBCAndEraseKey added in v1.7.25

func NewAESCBCAndEraseKey(safeKeyBuf, safeIvBuf []byte) (*Symmetric, error)

func NewAESCBCWithOutEraseKey added in v1.7.25

func NewAESCBCWithOutEraseKey(safeKeyBuf, safeIvBuf []byte) (*Symmetric, error)

func NewAESGCM added in v1.7.25

func NewAESGCM(safeKeyBuf, safeIvBuf *SafeBuf) (*Symmetric, error)

func NewAESGCMAndEraseKey added in v1.7.25

func NewAESGCMAndEraseKey(safeKeyBuf, safeIvBuf []byte) (*Symmetric, error)

func NewAESGCMWithOutEraseKey added in v1.7.25

func NewAESGCMWithOutEraseKey(safeKeyBuf, safeIvBuf []byte) (*Symmetric, error)

func NewSymmetric added in v1.7.25

func NewSymmetric(cipher SymmetricCipher, safeKeyBuf, safeIvBuf *SafeBuf) (*Symmetric, error)

func NewSymmetricAndEraseKey added in v1.7.25

func NewSymmetricAndEraseKey(cipher SymmetricCipher, key, iv []byte) (*Symmetric, error)

func NewSymmetricWithOutEraseKey added in v1.7.25

func NewSymmetricWithOutEraseKey(cipher SymmetricCipher, key, iv []byte) (*Symmetric, error)

func (*Symmetric) Close added in v1.7.25

func (_this *Symmetric) Close()

func (*Symmetric) Decrypt added in v1.7.25

func (_this *Symmetric) Decrypt(data []byte) (*SafeBuf, error)

func (*Symmetric) DecryptBytes added in v1.7.25

func (_this *Symmetric) DecryptBytes(data []byte) ([]byte, error)

func (*Symmetric) DecryptBytesN added in v1.7.25

func (_this *Symmetric) DecryptBytesN(data []byte) []byte

func (*Symmetric) Encrypt added in v1.7.25

func (_this *Symmetric) Encrypt(safeBuf *SafeBuf) ([]byte, error)

func (*Symmetric) EncryptBytes added in v1.7.25

func (_this *Symmetric) EncryptBytes(data []byte) ([]byte, error)

type SymmetricCipher added in v1.7.25

type SymmetricCipher interface {
	Encrypt(data []byte, key []byte, iv []byte) ([]byte, error)
	Decrypt(data []byte, key []byte, iv []byte) ([]byte, error)
}

type TextColor

type TextColor int
const (
	TextBlack TextColor = iota + 30
	TextRed
	TextGreen
	TextYellow
	TextBlue
	TextMagenta
	TextCyan
	TextWhite
	TextNone TextColor = 0
)

type X25519Algorithm added in v1.7.25

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

func NewX25519Algorithm added in v1.7.25

func NewX25519Algorithm(useGCM bool, hash crypto.Hash, kdfInfo, kdfSalt []byte) *X25519Algorithm

func (*X25519Algorithm) Decrypt added in v1.7.25

func (x *X25519Algorithm) Decrypt(privateKeyObj any, data []byte) ([]byte, error)

func (*X25519Algorithm) Encrypt added in v1.7.25

func (x *X25519Algorithm) Encrypt(publicKeyObj any, data []byte) ([]byte, error)

func (*X25519Algorithm) ParsePrivateKey added in v1.7.25

func (x *X25519Algorithm) ParsePrivateKey(der []byte) (any, error)

func (*X25519Algorithm) ParsePublicKey added in v1.7.25

func (x *X25519Algorithm) ParsePublicKey(der []byte) (any, error)

func (*X25519Algorithm) Sign added in v1.7.25

func (x *X25519Algorithm) Sign(privateKeyObj any, data []byte, hash ...crypto.Hash) ([]byte, error)

func (*X25519Algorithm) Verify added in v1.7.25

func (x *X25519Algorithm) Verify(publicKeyObj any, data []byte, signature []byte, hash ...crypto.Hash) (bool, error)

Jump to

Keyboard shortcuts

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