util

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateFileHash

func CalculateFileHash(file afero.File) ([]byte, error)

计算文件的SHA-256 hash

func CalculateHash

func CalculateHash(data []byte) []byte

计算[]byte的SHA-256 hash值

func CheckAndMkdir

func CheckAndMkdir(dirPath string) error

CheckAndMkdir 检查文件夹是否存在,不存在则新建

func DecodeFromBytes

func DecodeFromBytes(data []byte, result interface{}) error

DecodeFromBytes 使用 gob 解码将 []byte 转换为指定的数据结构

func EncodeToBytes

func EncodeToBytes(data interface{}) ([]byte, error)

EncodeToBytes 使用 gob 编码将任意数据转换为 []byte

func FromBytes

func FromBytes[T any](data []byte) (T, error)

FromBytes 泛型函数,用于将 []byte 转换回指定类型

func MergeFieldsForSigning

func MergeFieldsForSigning(fields ...interface{}) ([]byte, error)

MergeFieldsForSigning 接受任意数量和类型的字段,将它们序列化并合并为一个 []byte。

func SeparateHashFromData

func SeparateHashFromData(combinedData []byte) ([]byte, []byte, error)

SeparateHashFromData 从数据中分离出SHA-256哈希值和原始数据

func ToBytes

func ToBytes[T any](data T) ([]byte, error)

ToBytes 泛型函数,用于将不同类型的数据转换为 []byte

Types

This section is empty.

Directories

Path Synopsis
crypto
cbc
ctr
gcm
sign
rsa
zip

Jump to

Keyboard shortcuts

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