Documentation ¶
Index ¶
- func AesDecrypt(cipherText string, keys []byte) (string, error)
- func AesDecryptBytes(encrypted, keys []byte) ([]byte, error)
- func AesDecryptStr(cipherText, keysStr string) (string, error)
- func AesEncrypt(plainText string, keys []byte) (string, error)
- func AesEncryptBytes(plainTextBytes, keys []byte) ([]byte, error)
- func AesEncryptStr(plainText string) (string, string, error)
- func AesEncryptStr2(cipherText, keysStr string) (string, error)
- func AliyunSign(stringToSign, accessKeySecret, secretSuffix string) string
- func AliyunSignature(signedParams map[string]string, method string, secret string) string
- func Base64DecodeString(s string) ([]byte, error)
- func Base64DecodeStringURL(s string) ([]byte, error)
- func Base64EncodeToString(src []byte) string
- func Base64EncodeToStringURL(src []byte) string
- func BytesNetworkOrder2Number(bytesInNetworkOrder []byte) int
- func CODE(length int) string
- func CompareHashAndPassword(hashedPassword, password []byte) error
- func DecodeBaseX32(code string) (int64, error)
- func DecodeBaseX64(code string) (int64, error)
- func EncodeBaseX32(code int64) string
- func EncodeBaseX62(code int64) string
- func EncodeBaseX64(code int64) string
- func FixPreStrLen(pstr string, plen int) string
- func FixPreStrLen2(pstr string, plen int) string
- func FixRandomAes32(str string) string
- func FixSufStrLen(pstr string, plen int) string
- func GenerateFromPassword(password []byte, cost int) ([]byte, error)
- func MD5Hash(b []byte) string
- func MD5HashString(s string) string
- func MaskDecrypt(buffers []byte, randoms []byte) []byte
- func MaskEncrypt(buffers []byte, randoms []byte) []byte
- func Number2BytesInNetworkOrder(number int) []byte
- func PKCS7Padding(cipherText []byte, blockSize int) []byte
- func PKCS7UnPadding(origData []byte, blockSize int) []byte
- func RandomAes32() string
- func RandomBytes(length int) []byte
- func Reverse(str string) string
- func SHA1Hash(b []byte) string
- func SHA1HashString(s string) string
- func UUID(length int) string
- func UUID2(length int) string
- func WxGenMD5(datas map[string]string, sign string) string
- func WxGenSHA1(arr ...string) string
- func WxGenSHA1And(arr ...string) string
- func WxPKCS7Decode(decrypted []byte) []byte
- func WxPKCS7Encode(count int) []byte
- type WxAccessToken
- type WxCrypto
- type WxEncryptMessage
- type WxEncryptSignature
- type WxSignature
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AesDecryptBytes ¶
AesDecryptBytes aes
func AesDecryptStr ¶
AesDecryptStr aes
func AesEncryptBytes ¶
AesEncryptBytes aes
func AesEncryptStr2 ¶
AesEncryptStr2 aes
func AliyunSign ¶
AliyunSign ...
func AliyunSignature ¶
AliyunSignature ... *
- @see https://github.com/alibabacloud-go/openapi-util/blob/c929a595b5b8321f44ceee2afcd84ea744f56df6/service/service.go#L475
- @param signedParams params which need to be signed
- @param method http method e.g. GET
- @param secret AccessKeySecret
- @return the signature
func Base64DecodeString ¶
Base64DecodeString returns the bytes represented by the base64 string s. RFC 4648.
func Base64DecodeStringURL ¶
Base64DecodeStringURL returns the bytes represented by the base64 string s.
func Base64EncodeToString ¶
Base64EncodeToString returns the base64 encoding of src. RFC 4648.
func Base64EncodeToStringURL ¶
Base64EncodeToStringURL returns the base64 encoding of src.
func BytesNetworkOrder2Number ¶
BytesNetworkOrder2Number 4个字节的网络字节序bytes数组还原成一个数字
func CompareHashAndPassword ¶
CompareHashAndPassword compares a bcrypt hashed password with its possible plaintext equivalent. Returns nil on success, or an error on failure.
func FixPreStrLen2 ¶
FixPreStrLen2 获取固定长度内容,不够前段补齐0, 超长, 保留原始数据
func GenerateFromPassword ¶
GenerateFromPassword returns the bcrypt hash of the password at the given cost. If the cost given is less than MinCost, the cost will be set to DefaultCost, instead. Use CompareHashAndPassword, as defined in this package, to compare the returned hashed password with its cleartext version.
func MaskEncrypt ¶
MaskEncrypt 简单的加密算法, 破坏其本身字符串的特征, 当用于对同一个MD5值进行处理
func Number2BytesInNetworkOrder ¶
Number2BytesInNetworkOrder 将一个数字转换成生成4个字节的网络字节序bytes数组
func PKCS7Padding ¶
PKCS7Padding 使用PKCS7进行填充
func PKCS7UnPadding ¶
PKCS7UnPadding 删除PKCS7填充
func WxPKCS7Decode ¶
WxPKCS7Decode 删除解密后明文的补位字符 param decrypted 解密后的明文 return 删除补位字符后的明文
func WxPKCS7Encode ¶
WxPKCS7Encode 获得对明文进行补位填充的字节. param count 需要进行填充补位操作的明文字节个数 return 补齐用的字节数组
Types ¶
type WxAccessToken ¶
type WxAccessToken struct { AccessToken string `json:"access_token"` ExpiresIn string `json:"expires_in"` }
WxAccessToken access token
type WxCrypto ¶
WxCrypto wechat 加密
func WxNewCrypto ¶
WxNewCrypto 注意,来自微信的AesKey需要增加一个"="符号,推荐使用WxNewCrypto2处理
func WxNewCrypto2 ¶
WxNewCrypto2 new
type WxEncryptMessage ¶
type WxEncryptMessage struct { ToUserName string `json:",omitempty"` // ToUserName为公众号AppId或者企业号的CorpID AgentID string `json:",omitempty"` // 为接收的应用id,可在应用的设置页面获取 只有企业号,该字段才有值 Encrypt string `json:",omitempty"` // 密文 encrypt为经过加密的密文(消息明文格式参见 接收普通消息,事件明文格式参见 接收事件) MsgSignature string `json:",omitempty"` // 密文签名 TimeStamp string `json:",omitempty"` // 密文时间戳 Nonce string `json:",omitempty"` // 密文随机码 }
WxEncryptMessage 加密文件存储
type WxEncryptSignature ¶
type WxEncryptSignature struct { WxSignature MsgSignature string `query:"msg_signature"` EncryptType string `query:"encrypt_type"` }
WxEncryptSignature jsapi signature