Documentation ¶
Index ¶
- Variables
- func Base64Decode(s string) ([]byte, error)
- func Base64Encode(src []byte) string
- func BytesSplit(buf []byte, size int) [][]byte
- func BytesToString(buf []byte) string
- func CryptoHashSum(typ string, slices ...[]byte) ([]byte, error)
- func EncodeDerToPem(data []byte, blockType string) []byte
- func GenRandom(n int) ([]byte, error)
- func GetBlockTypeFromName(name string) string
- func GetCryptoHash(typ string) (crypto.Hash, error)
- func HashNames() []string
- func HashSum(typ string, slices ...[]byte) ([]byte, error)
- func HexDecode(s string) ([]byte, error)
- func HexEncode(src []byte) string
- func HexPadding(text string, size int) string
- func NewError(errs ...error) error
- func ParsePemToDer(data []byte) ([]byte, error)
- func StringToBytes(str string) []byte
- type Block
- type Cipher
- type CipherFunc
- type CipherFuncMap
- type Config
- func (this *Config) All() map[string]any
- func (this *Config) Clean()
- func (this *Config) Get(name string) any
- func (this *Config) GetBool(name string) bool
- func (this *Config) GetBoolSlice(name string) []bool
- func (this *Config) GetBytes(name string) []byte
- func (this *Config) GetDuration(name string) time.Duration
- func (this *Config) GetDurationSlice(name string) []time.Duration
- func (this *Config) GetFloat32(name string) float32
- func (this *Config) GetFloat64(name string) float64
- func (this *Config) GetInt(name string) int
- func (this *Config) GetInt16(name string) int16
- func (this *Config) GetInt32(name string) int32
- func (this *Config) GetInt64(name string) int64
- func (this *Config) GetInt8(name string) int8
- func (this *Config) GetIntSlice(name string) []int
- func (this *Config) GetSlice(name string) []any
- func (this *Config) GetString(name string) string
- func (this *Config) GetStringMap(name string) map[string]any
- func (this *Config) GetStringMapBool(name string) map[string]bool
- func (this *Config) GetStringMapInt(name string) map[string]int
- func (this *Config) GetStringMapInt64(name string) map[string]int64
- func (this *Config) GetStringMapString(name string) map[string]string
- func (this *Config) GetStringMapStringSlice(name string) map[string][]string
- func (this *Config) GetStringSlice(name string) []string
- func (this *Config) GetTime(name string) time.Time
- func (this *Config) GetUint(name string) uint
- func (this *Config) GetUint16(name string) uint16
- func (this *Config) GetUint32(name string) uint32
- func (this *Config) GetUint64(name string) uint64
- func (this *Config) GetUint8(name string) uint8
- func (this *Config) Has(name string) bool
- func (this *Config) Len() int
- func (this *Config) Names() []string
- func (this *Config) Remove(name string) *Config
- func (this *Config) Set(name string, data any) *Config
- func (this *Config) String() string
- func (this *Config) WithData(data map[string]any) *Config
- type Encoding
- type Errors
- func (this *Errors) All() []error
- func (this *Errors) Append(errs ...error) *Errors
- func (this *Errors) Count() int
- func (this *Errors) Error() string
- func (this *Errors) First() error
- func (this *Errors) Get(n int) error
- func (this *Errors) IsNil() bool
- func (this *Errors) Last() error
- func (this *Errors) Prepend(errs ...error) *Errors
- func (this *Errors) Range(fn func(int, error))
- func (this *Errors) Reset() *Errors
- func (this *Errors) String() string
- func (this *Errors) Unwrap() []error
- func (this *Errors) WithErrors(errs []error) *Errors
- type Hash
- type HashFunc
- type Padding
- func (this Padding) ISO10126Padding(text []byte, blockSize int) []byte
- func (this Padding) ISO10126UnPadding(src []byte) []byte
- func (this Padding) ISO7816_4Padding(text []byte, blockSize int) []byte
- func (this Padding) ISO7816_4UnPadding(src []byte) []byte
- func (this Padding) ISO97971Padding(text []byte, blockSize int) []byte
- func (this Padding) ISO97971UnPadding(src []byte) []byte
- func (this Padding) PKCS1Padding(text []byte, blockSize int, bt string) []byte
- func (this Padding) PKCS1UnPadding(src []byte) []byte
- func (this Padding) PKCS5Padding(text []byte) []byte
- func (this Padding) PKCS5UnPadding(src []byte) []byte
- func (this Padding) PKCS7Padding(text []byte, blockSize int) []byte
- func (this Padding) PKCS7UnPadding(src []byte) []byte
- func (this Padding) RandomBytes(length uint) []byte
- func (this Padding) TBCPadding(text []byte, blockSize int) []byte
- func (this Padding) TBCUnPadding(src []byte) []byte
- func (this Padding) X923Padding(text []byte, blockSize int) []byte
- func (this Padding) X923UnPadding(src []byte) []byte
- func (this Padding) ZeroPadding(text []byte, blockSize int) []byte
- func (this Padding) ZeroUnPadding(src []byte) []byte
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 Base64Encode ¶ added in v1.0.2002
func CryptoHashSum ¶ added in v1.0.2003
签名后数据
func EncodeDerToPem ¶ added in v1.0.1033
der 证书编码为 pem 证书
func GetBlockTypeFromName ¶ added in v1.0.1033
获取 BlockType 类型
func HexPadding ¶ added in v1.0.2002
func ParsePemToDer ¶ added in v1.0.1033
解析 pem 证书为 der 证书
Types ¶
type Cipher ¶
type Cipher struct {
// contains filtered or unexported fields
}
*
- 加密方式 *
- @create 2022-7-26
- @author deatil
type Config ¶ added in v1.0.1046
type Config struct {
// contains filtered or unexported fields
}
*
- 配置 *
- @create 2023-2-13
- @author deatil
func (*Config) GetBoolSlice ¶ added in v1.0.1046
func (*Config) GetDuration ¶ added in v1.0.1046
func (*Config) GetDurationSlice ¶ added in v1.0.1046
func (*Config) GetFloat32 ¶ added in v1.0.1046
func (*Config) GetFloat64 ¶ added in v1.0.1046
func (*Config) GetIntSlice ¶ added in v1.0.1046
func (*Config) GetStringMap ¶ added in v1.0.1046
func (*Config) GetStringMapBool ¶ added in v1.0.1046
func (*Config) GetStringMapInt ¶ added in v1.0.1046
func (*Config) GetStringMapInt64 ¶ added in v1.0.1046
func (*Config) GetStringMapString ¶ added in v1.0.1046
func (*Config) GetStringMapStringSlice ¶ added in v1.0.1046
func (*Config) GetStringSlice ¶ added in v1.0.1046
type Encoding ¶
type Encoding struct{}
*
- 编码 *
- @create 2022-4-17
- @author deatil
func (Encoding) Base64Decode ¶
Base64 解码
type Errors ¶ added in v1.0.1026
type Errors struct {
// contains filtered or unexported fields
}
*
- 错误记录 *
- @create 2022-8-10
- @author deatil
func (*Errors) WithErrors ¶ added in v1.0.1026
设置
type Hash ¶
type Hash struct {
// contains filtered or unexported fields
}
*
- 摘要 *
- @create 2022-4-16
- @author deatil
type Padding ¶
type Padding struct{}
*
- 补码 *
- @create 2022-4-17
- @author deatil
func (Padding) ISO10126Padding ¶
ISO10126Padding 填充至符合块大小的整数倍,填充值最后一个字节为填充的数量数,其他字节填充随机字节。
func (Padding) ISO10126UnPadding ¶
func (Padding) ISO7816_4Padding ¶
ISO7816_4Padding 填充至符合块大小的整数倍,填充值第一个字节为0x80,其他字节填0x00。
func (Padding) ISO7816_4UnPadding ¶
func (Padding) ISO97971Padding ¶ added in v1.0.1026
ISO/IEC 9797-1 Padding Method 2
func (Padding) ISO97971UnPadding ¶ added in v1.0.1026
func (Padding) PKCS1Padding ¶
填充格式如下: Padding = 00 + BT + PS + 00 + D 00为固定字节 BT为处理模式 PS为填充字节,填充数量为k - 3 - D,k表示密钥长度, D表示原文长度。 PS的最小长度为8个字节。填充的值根据BT值来定: BT = 00时,填充全00 BT = 01时,填充全FF BT = 02时,随机填充,但不能为00。
func (Padding) PKCS1UnPadding ¶
func (Padding) PKCS5Padding ¶
PKCS7Padding的子集,块大小固定为8字节
func (Padding) PKCS5UnPadding ¶
func (Padding) PKCS7Padding ¶
明文补码算法 填充至符合块大小的整数倍,填充值为填充数量数
func (Padding) TBCPadding ¶
TBCPadding(Trailling-Bit-Compliment) 填充至符合块大小的整数倍,原文最后一位为1时填充0x00,最后一位为0时填充0xFF。
func (Padding) TBCUnPadding ¶
func (Padding) X923Padding ¶
X923Padding 填充至符合块大小的整数倍,填充值最后一个字节为填充的数量数,其他字节填0
func (Padding) X923UnPadding ¶
func (Padding) ZeroPadding ¶
数据长度不对齐时使用0填充,否则不填充
func (Padding) ZeroUnPadding ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.