benc

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package benc 是用来处理加密的包

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AesDecFromBase64 added in v0.0.4

func AesDecFromBase64(base64Str string, key []byte) ([]byte, error)

AesDecFromBase64 数据解密

func AesEncToBase64 added in v0.0.4

func AesEncToBase64(originData, key []byte) (string, error)

AesEncToBase64 将数据 aes 加密, 并转成 base64 格式

func PKCS5Padding

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

PKCS5Padding 填充

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

PKCS5UnPadding 填充

func PwdSlat

func PwdSlat(password, slat string) string

PwdSlat 给密码通过盐加密

func StrToMd5 added in v0.0.3

func StrToMd5(b string) string

StrToMd5 将 []byte 加密成 md5

func StrToSha256 added in v0.0.3

func StrToSha256(b string) string

StrToSha256 将 []byte 加密成 md5

Types

type AesStruct added in v0.0.4

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

AesStruct 为 Aes 操作定义一个结构

func NewAesEncrypt added in v0.0.4

func NewAesEncrypt(origData, key []byte) (*AesStruct, error)

NewAesEncrypt 初始化 aes 的结构

func NewAesEncryptFromBase64 added in v0.0.4

func NewAesEncryptFromBase64(base64Str string, key []byte) (*AesStruct, error)

NewAesEncryptFromBase64 从 base64 字符串实例化

func (*AesStruct) CBCDecrypt added in v0.0.4

func (as *AesStruct) CBCDecrypt() error

CBCDecrypt CBC 解密

func (*AesStruct) CBCEncrypt added in v0.0.4

func (as *AesStruct) CBCEncrypt() error

CBCEncrypt CBC 加密

func (*AesStruct) GetCryptedData added in v0.0.4

func (as *AesStruct) GetCryptedData() []byte

GetCryptedData 获取加密或解密后的结果

func (*AesStruct) GetCryptedDataBase64 added in v0.0.4

func (as *AesStruct) GetCryptedDataBase64() string

GetCryptedDataBase64 获取 base64 格式的加密结果

func (*AesStruct) GetIV added in v0.0.4

func (as *AesStruct) GetIV() []byte

GetIV 获取 IV 的值

func (*AesStruct) GetKey added in v0.0.4

func (as *AesStruct) GetKey() []byte

GetKey 获取 key 的内容

func (*AesStruct) SetIV added in v0.0.4

func (as *AesStruct) SetIV(iv []byte) error

SetIV 设置 IV, 需要注意的, IV 必须是 16 位

func (*AesStruct) SetKey added in v0.0.4

func (as *AesStruct) SetKey(key []byte) error

SetKey 设置加密的 key 这里不管传入的 key 是什么, 只要不为空即可, 转换成 md5 去使用

func (*AesStruct) SetOriginData added in v0.0.4

func (as *AesStruct) SetOriginData(originData []byte) error

SetOriginData 设置需要加密的数据

Jump to

Keyboard shortcuts

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