Documentation
¶
Index ¶
- Constants
- Variables
- func AESCBCDecrypt(c, k []byte) ([]byte, error)
- func AESCBCEncrypt(s, k []byte) ([]byte, error)
- func AESCFBDecrypt(c, k []byte) ([]byte, error)
- func AESCFBEncrypt(s, k []byte) ([]byte, error)
- func AESGCMDecrypt(c, k, n []byte) ([]byte, error)
- func AESGCMEncrypt(s, k, n []byte) ([]byte, error)
- func AESMake256Key(k []byte) []byte
- func CheckHmacSha1(message, messageMAC, key []byte) (bool, error)
- func CheckHmacSha256(message, messageMAC, key []byte) (bool, error)
- func Decimal2IP(n int64) string
- func Decimal2IP0(n int64) (ip string, err error)
- func Decimal2IP1(n int64) string
- func DecryptStruct(d []byte, v interface{}, k []byte) error
- func DecryptStructFrom(r io.Reader, v interface{}, k []byte) error
- func EncryptStruct(v interface{}, k []byte) ([]byte, error)
- func EncryptStructTo(w io.Writer, v interface{}, k []byte) error
- func GBK2UTF8(s []byte) ([]byte, error)
- func GetAddressFromURL(s string) (string, error)
- func HasPort(host string) bool
- func HkdfSha1RandomSalt(secret, info []byte, sl int) (key []byte, salt []byte, err error)
- func HkdfSha1WithSalt(secret, salt, info []byte) (key []byte, err error)
- func HkdfSha256RandomSalt(secret, info []byte, sl int) (key []byte, salt []byte, err error)
- func HkdfSha256WithSalt(secret, salt, info []byte) (key []byte, err error)
- func HmacSha1(message, key []byte) ([]byte, error)
- func HmacSha256(message, key []byte) ([]byte, error)
- func IP2Decimal(ipstr string) (int64, error)
- func IP2Decimal0(ip string) (n int64, err error)
- func IP2Decimal1(ipstr string) (int64, error)
- func IsBankCard(n int64) (ok bool, err error)
- func IsChineseID(s string) (ok bool, err error)
- func IsChineseWords(words string) (ok bool, err error)
- func IsEmail(email string) (ok bool, err error)
- func JSON(w http.ResponseWriter, v interface{})
- func MD5(s string) (r string)
- func Markdown(markdown []byte) (html []byte)
- func MultipartFormDataFromFile(params, files map[string][]string, boundary string) (ior io.Reader, err error)
- func MultipartFormDataFromReader(params map[string][]string, files map[string][]io.Reader, boundary string) (ior io.Reader, err error)
- func OpenRedPacket(amount, quantity int64) int64
- func PKCS5Padding(c []byte, blockSize int) []byte
- func PKCS5UnPadding(s []byte) ([]byte, error)
- func Random(min, max int64) int64
- func RandomNumber() (i int64)
- func ReadJSON(r *http.Request, o interface{}) error
- func SHA1(s string) (r string)
- func SHA256(s []byte) ([]byte, error)
- func SHA256String(s string) (r string)
- func ToString(data interface{}) (string, error)
- func URIEscape(s string) string
- func URIUnescape(s string) (string, error)
- func UTF82GBK(s []byte) ([]byte, error)
- type CIDRInfo
- type Chat
- type CryptKV
- type DB
- func (db *DB) Begin() (*Tx, error)
- func (db *DB) Delete(o interface{}) error
- func (db *DB) Get(id int64, o interface{}) error
- func (db *DB) Insert(o interface{}) (int64, error)
- func (db *DB) Update(o interface{}) error
- func (db *DB) UpdateExcept(o interface{}, ignore ...string) error
- func (db *DB) UpdateOnly(o interface{}, only ...string) error
- type Dial
- type Dialer
- type JPush
- type Mailgun
- type SafeMap
- type TencentSMS
- type Tx
- func (tx *Tx) Commit() error
- func (tx *Tx) Delete(o interface{}) error
- func (tx *Tx) Get(id int64, o interface{}) error
- func (tx *Tx) Insert(o interface{}) (int64, error)
- func (tx *Tx) Rollback(err error) error
- func (tx *Tx) Update(o interface{}) error
- func (tx *Tx) UpdateExcept(o interface{}, ignore ...string) error
- func (tx *Tx) UpdateOnly(o interface{}, only ...string) error
- type YunpianSMS
Constants ¶
const AES256KeyLength = 32
AES256KeyLength is the length of key for AES 256 crypt
const MailgunAPIURL = "https://api.mailgun.net/v3"
MailgunAPIURL is the base url of maingun api
Variables ¶
var DefaultDial = &Dial{ Timeout: 10 * time.Second, }
Functions ¶
func AESCBCDecrypt ¶
AESCBCDecrypt decrypt c with given k k should be 128/256 bits, otherwise it will append empty data or cut until 256 bits First 16 bytes of cipher data is the IV.
func AESCBCEncrypt ¶
AESCBCEncrypt encrypt s with given k k should be 128/256 bits, otherwise it will append empty data or cut until 256 bits First 16 bytes of cipher data is the IV.
func AESCFBDecrypt ¶
AESDecrypt decrypt c with given k k should be 128/256 bits, otherwise it will append empty data or cut until 256 bits First 16 bytes of cipher data is the IV.
func AESCFBEncrypt ¶
AESCFBEncrypt encrypt s with given k. k should be 128/256 bits, otherwise it will append empty data or cut until 256 bits. First 16 bytes of cipher data is the IV.
func AESGCMDecrypt ¶
AESGCMDecrypt decrypt s use k and nonce
func AESGCMEncrypt ¶
AESGCMEncrypt encrypt s use k and nonce
func AESMake256Key ¶
AESMake256Key cut or append empty data on the key and make sure the key lenth equal 32
func CheckHmacSha1 ¶
func CheckHmacSha256 ¶
func Decimal2IP ¶
Decimal2IP transform a decimal IP to x.x.x.x format.
func Decimal2IP0 ¶
Decimal2IP0 transform a decimal IP to x.x.x.x format. ref: https://zh.wikipedia.org/wiki/IPv4
func Decimal2IP1 ¶
Decimal2IP1 transform a decimal IP to x.x.x.x format.
func DecryptStructFrom ¶
JSON Struct
func GetAddressFromURL ¶
func HkdfSha1RandomSalt ¶
func HkdfSha1WithSalt ¶
func HkdfSha256RandomSalt ¶
func HkdfSha256WithSalt ¶
func HmacSha256 ¶
func IP2Decimal ¶
IP2Decimal transform ip format like x.x.x.x to decimal.
func IP2Decimal0 ¶
IP2Decimal0 transform ip format like x.x.x.x to decimal. ref: https://zh.wikipedia.org/wiki/IPv4
func IP2Decimal1 ¶
IP2Decimal1 transform ip format like x.x.x.x to decimal.
func IsBankCard ¶
IsBankCard determine whether it is bankcard number
func IsChineseID ¶
IsChineseID determine whether it is Chinese ID Card Number
func IsChineseWords ¶
IsChineseWords determine whether it is Chinese words Notice: NOT ALL
func JSON ¶
func JSON(w http.ResponseWriter, v interface{})
func MultipartFormDataFromFile ¶
func MultipartFormDataFromFile(params, files map[string][]string, boundary string) (ior io.Reader, err error)
MultipartFormDataFromFile generate multipart form data according to RFC 2388. files is the paths of your files
func MultipartFormDataFromReader ¶
func MultipartFormDataFromReader(params map[string][]string, files map[string][]io.Reader, boundary string) (ior io.Reader, err error)
MultipartFormDataFromReader generate multipart form data according to RFC 2388.
func OpenRedPacket ¶
OpenRedPacket opens a red packet, amount and quantity are remaining data. amount and quantity must > 0. amount must >= quantity.
func PKCS5Padding ¶
PKCS5Padding can append data of PKCS5 Common blockSize is aes.BlockSize
func PKCS5UnPadding ¶
PKCS5UnPadding can unappend data of PKCS5
func SHA256String ¶
SHA256 encrypt s according to sha256 algorithm
func ToString ¶
ToString convert data to string, data must be one of map[string]string, map[string]interface{}, string, []string, struct
func URIUnescape ¶
Types ¶
type CryptKV ¶
CryptKV can be used to crypt value by key and give it a lifecycle (s). Can be used in cookies
func (*CryptKV) DecryptFromRequest ¶
Decrypt from http.Request
type JPush ¶
type SafeMap ¶
type SafeMap struct {
// contains filtered or unexported fields
}
SafeMap is concurrent security map
func (*SafeMap) Get ¶
func (m *SafeMap) Get(k interface{}) interface{}
Get used to get a value by key
type TencentSMS ¶
func (*TencentSMS) Send ¶
func (t *TencentSMS) Send(message, mobile string) error
type YunpianSMS ¶
type YunpianSMS struct {
ApiKey string
}
func (*YunpianSMS) Send ¶
func (y *YunpianSMS) Send(message, mobile string) error