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 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 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 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 PKCS5Padding(c []byte, blockSize int) []byte
- func PKCS5UnPadding(s []byte) ([]byte, error)
- func Random(min, max int64) int64
- func RandomNumber() (i int64)
- 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 UTF82GBK(s []byte) ([]byte, error)
- type CIDRInfo
- type CryptKV
- type Dial
- type Dialer
- type SafeMap
- type Slack
Constants ¶
const AES256KeyLength = 32
AES256KeyLength is the length of key for AES 256 crypt
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 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 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 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
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 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