cryptos

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CharsetIso2022Jp         GolangCharset = "ISO-2022-JP"
	CharsetIso2022Cn                       = "ISO-2022-CN"
	CharsetIso2022Kr                       = "ISO-2022-KR"
	CharsetIso88595                        = "ISO-8859-5"
	CharsetIso88597                        = "ISO-8859-7"
	CharsetIso88598                        = "ISO-8859-8"
	CharsetBig5                            = "BIG5"
	CharsetGb18030                         = "GB18030"
	CharsetEucJp                           = "EUC-JP"
	CharsetEucKr                           = "EUC-KR"
	CharsetEucTw                           = "EUC-TW"
	CharsetShiftJis                        = "SHIFT_JIS"
	CharsetIbm855                          = "IBM855"
	CharsetIbm866                          = "IBM866"
	CharsetKoi8R                           = "KOI8-R"
	CharsetMacCyrillic                     = "x-mac-cyrillic"
	CharsetWindows1251                     = "WINDOWS-1251"
	CharsetWindows1252                     = "WINDOWS-1252"
	CharsetWindows1253                     = "WINDOWS-1253"
	CharsetWindows1255                     = "WINDOWS-1255"
	CharsetUtf8                            = "UTF-8"
	CharsetUtf16Be                         = "UTF-16BE"
	CharsetUtf16Le                         = "UTF-16LE"
	CharsetUtf32Be                         = "UTF-32BE"
	CharsetUtf32Le                         = "UTF-32LE"
	CharsetTis620                          = "WINDOWS-874"
	CharsetHzGb2312                        = "HZ-GB-2312"
	CharsetXIso10646Ucs43412               = "X-ISO-10646-UCS-4-3412"
	CharsetXIso10646Ucs42143               = "X-ISO-10646-UCS-4-2143"
)

字符编码类型常量

Variables

This section is empty.

Functions

func DeSkip32

func DeSkip32(key string, value uint32) (uint32, error)

DeSkip32 解密

func DecodeAESCBC

func DecodeAESCBC(data, key []byte) (contentBytes []byte, err error)

DecodeAESCBC aes-256-cbc AES/CBC/PKCS5Padding

AES_CBC加密解密的算法为: aes-256-cbc, iv初始向量为随机16位字符串, padding为PKCS5Padding, 常用于HTTP中, 过程如下: 1.客户端发送加密请求体 ---> 2.服务器接收请求体并解密 ---> 3.服务器处理请求,返回加密响应体 ---> 4.客户端接收响应体并解密

解密数据处理的流程为: 先将iv拼接加密的数据进行Base64解码, 然后按照aes-256-cbc用key和iv对数据进行解密, 最后对数据进行zlib 6 level解压 即 AES_CBC解密: base64解密 --> AES解密 --> 解压缩

func DecodeAESGCM

func DecodeAESGCM(data, key []byte) (contentBytes []byte, err error)

DecodeAESGCM aes-256-gcm AES/GCM/NoPadding

AES_GCM加密解密的算法为: aes-256-gcm, nonce为随机12位字符串, padding为NoPadding, 常用于HTTP中, 过程如下: 1.客户端发送加密请求体 ---> 2.服务器接收请求体并解密 ---> 3.服务器处理请求,返回加密响应体 ---> 4.客户端接收响应体并解密

解密数据处理的流程为: 先将nonce拼接加密的数据进行Base64解码, 然后按照aes-256-gcm用key和nonce对数据进行解密, 最后对数据进行zlib 6 level解压 即 AES_GCM解密: base64解密 --> AES解密 --> 解压缩

func EnSHA256

func EnSHA256(value string) string

EnSHA256 SHA256加密

func EnSkip32

func EnSkip32(key string, value uint32) (uint32, error)

EnSkip32 加密

func EncodeAESCBC

func EncodeAESCBC(data, key []byte) (base64ContentBytes []byte, err error)

EncodeAESCBC aes-256-cbc AES/CBC/PKCS5Padding

AES_CBC加密解密的算法为: aes-256-cbc, iv初始向量为随机16位字符串, padding为PKCS5Padding, 常用于HTTP中, 过程如下: 1.客户端发送加密请求体 ---> 2.服务器接收请求体并解密 ---> 3.服务器处理请求,返回加密响应体 ---> 4.客户端接收响应体并解密

加密数据处理的流程为: 先对数据进行zlib 6 level压缩, 然后按照aes-256-cbc用key和iv对数据进行加密, 最后对iv拼接加密的数据进行Base64编码 即 AES_CBC加密: 压缩 --> AES加密 --> base64加密

func EncodeAESGCM

func EncodeAESGCM(data, key []byte) (base64ContentBytes []byte, nonceBytes []byte, err error)

func EncodeMD5

func EncodeMD5(value string) string

EncodeMD5 Md5加密(返回32位小写),该方法可以把字符串进行MD5加密,并把加密后的二进制转化为十六进制后的32位字符串返回

func RSADecryptionOaepSha256FromBase64 added in v0.1.2

func RSADecryptionOaepSha256FromBase64(privateKeyByte []byte, ciphertextBase64Bytes []byte) (contentBytes []byte, err error)

func RSAEncryptionOaepSha256ToBase64 added in v0.1.2

func RSAEncryptionOaepSha256ToBase64(publicKeyByte []byte, dataToEncryptBytes []byte) (base64ContentBytes []byte, err error)

Types

type GolangCharset

type GolangCharset string

GolangCharset 签名的字符编码类型

type MapExtend

type MapExtend struct {
}

func (*MapExtend) GetKeys

func (s *MapExtend) GetKeys(toSignMap *map[string]interface{}) (keys []string, err error)

func (*MapExtend) ToSignMap

func (s *MapExtend) ToSignMap(parameters *map[string]interface{}) map[string]interface{}

ToSignMap 形成符合签名格式的Map

type SignUtils

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

SignUtils 签名类

func NewSign

func NewSign() *SignUtils

NewSign 实例化签名

func (*SignUtils) GetUtf8Bytes

func (s *SignUtils) GetUtf8Bytes(str string) []byte

GetUtf8Bytes 默认utf8字符串

func (*SignUtils) SignTopRequest

func (s *SignUtils) SignTopRequest(parameters *map[string]interface{}, secret string, signMethod GolangCharset) string

SignTopRequest

签名算法 parameters 要签名的数据项 secret 生成的publicKey signMethod 签名的字符编码

Jump to

Keyboard shortcuts

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