tool

package
v1.0.4028 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// 编码
	// Encode(out io.Writer, b *Block) error
	Encode = pem.Encode

	// 编码
	// EncodeToMemory(b *Block) []byte
	EncodeToMemory = pem.EncodeToMemory

	// 解码
	// Decode(data []byte) (p *Block, rest []byte)
	Decode = pem.Decode
)
View Source
var PemBlockTypeMap = map[string]string{
	"pri_key":    "PRIVATE KEY",
	"en_pri_key": "ENCRYPTED PRIVATE KEY",
	"pub_key":    "PUBLIC KEY",

	"ec_pri_key":  "EC PRIVATE KEY",
	"dsa_pri_key": "DSA PRIVATE KEY",
	"rsa_pri_key": "RSA PRIVATE KEY",
}

BlockType 列表

Functions

func Base64Decode added in v1.0.2002

func Base64Decode(s string) ([]byte, error)

func Base64Encode added in v1.0.2002

func Base64Encode(src []byte) string

func BytesPadding added in v1.0.2039

func BytesPadding(text []byte, size int) []byte

func BytesSplit added in v1.0.1049

func BytesSplit(buf []byte, size int) [][]byte

根据指定长度分割字节

func BytesToString added in v1.0.1049

func BytesToString(buf []byte) string

字节转换为字符串

func CryptoHashSum added in v1.0.2003

func CryptoHashSum(typ string, slices ...[]byte) ([]byte, error)

签名后数据

func EncodeDerToPem added in v1.0.1033

func EncodeDerToPem(data []byte, blockType string) []byte

der 证书编码为 pem 证书

func GenRandom added in v1.0.1050

func GenRandom(n int) ([]byte, error)

随机生成字符

func GetBlockTypeFromName added in v1.0.1033

func GetBlockTypeFromName(name string) string

获取 BlockType 类型

func GetCryptoHash added in v1.0.2003

func GetCryptoHash(typ string) (crypto.Hash, error)

类型

func HashNames added in v1.0.2003

func HashNames() []string

func HashSum added in v1.0.2003

func HashSum(typ string, slices ...[]byte) ([]byte, error)

func HexDecode added in v1.0.2002

func HexDecode(s string) ([]byte, error)

func HexEncode added in v1.0.2002

func HexEncode(src []byte) string

func HexPadding added in v1.0.2002

func HexPadding(text string, size int) string

func ParsePemToDer added in v1.0.1033

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

解析 pem 证书为 der 证书

func StringToBytes added in v1.0.1049

func StringToBytes(str string) []byte

字符串转换为字节

Types

type Block added in v1.0.1033

type Block = pem.Block

Block

type Cipher

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

*

  • 加密方式 *
  • @create 2022-7-26
  • @author deatil

func NewCipher

func NewCipher() *Cipher

构造函数

func (*Cipher) AddFunc

func (this *Cipher) AddFunc(name string, block CipherFunc) *Cipher

添加

func (*Cipher) GetFunc

func (this *Cipher) GetFunc(name string) CipherFunc

类型

func (*Cipher) WithFunc

func (this *Cipher) WithFunc(funcs CipherFuncMap) *Cipher

覆盖

type CipherFunc

type CipherFunc = func([]byte) (cipher.Block, error)

CipherFunc

type CipherFuncMap

type CipherFuncMap = map[string]CipherFunc

CipherFunc map 列表

type Encoding

type Encoding struct{}

*

  • 编码 *
  • @create 2022-4-17
  • @author deatil

func NewEncoding

func NewEncoding() *Encoding

构造函数

func (*Encoding) Base64Decode

func (this *Encoding) Base64Decode(s string) ([]byte, error)

Base64 解码

func (*Encoding) Base64Encode

func (this *Encoding) Base64Encode(src []byte) string

Base64 编码

func (*Encoding) BytesPadding added in v1.0.2048

func (this *Encoding) BytesPadding(text []byte, size int) []byte

BytesPadding

func (*Encoding) HexDecode

func (this *Encoding) HexDecode(s string) ([]byte, error)

Hex 解码

func (*Encoding) HexEncode

func (this *Encoding) HexEncode(src []byte) string

Hex 编码

func (*Encoding) HexPadding

func (this *Encoding) HexPadding(text string, size int) string

补码

type Hash

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

*

  • 摘要 *
  • @create 2022-4-16
  • @author deatil

func AddHash added in v1.0.2003

func AddHash(name string, h HashFunc) *Hash

func NewHash

func NewHash() *Hash

构造函数

func (*Hash) AddHash

func (this *Hash) AddHash(name string, h HashFunc) *Hash

添加

func (*Hash) GetHash

func (this *Hash) GetHash(typ string) (HashFunc, error)

类型

func (*Hash) Names added in v1.0.2003

func (this *Hash) Names() []string

列席名称列表

func (*Hash) Sum added in v1.0.2003

func (this *Hash) Sum(typ string, slices ...[]byte) ([]byte, error)

签名后数据

type HashFunc added in v1.0.2003

type HashFunc = func() hash.Hash

HashFunc

func GetHash added in v1.0.2003

func GetHash(typ string) (HashFunc, error)

Directories

Path Synopsis
gcd
lcm

Jump to

Keyboard shortcuts

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