Documentation ¶
Index ¶
- Constants
- Variables
- func Abs(x int) int
- func AesDecrypt(cypted []byte, key []byte) (string, error)
- func AesDemo()
- func AesDemo2()
- func AesEncrypt(origData []byte, key []byte) ([]byte, error)
- func AnyToAny(src interface{}, des interface{}) error
- func Base64Dec(encodeString string) string
- func Base64DecUrl(encodeString string) string
- func Base64Enc(input []byte) string
- func Base64EncUrl(input []byte) string
- func Black(str string, modifier ...interface{}) string
- func Blue(str string, modifier ...interface{}) string
- func Brown(str string, modifier ...interface{}) string
- func CertInfo(certPath string, certBytes []byte) (*x509.Certificate, error)
- func CheckEmail(email string) error
- func Compress(srcDir, dstZipPath string) error
- func CurrentUTCTime() string
- func Cyan(str string, modifier ...interface{}) string
- func DarkGray(str string, modifier ...interface{}) string
- func DeTxtByAes(pwd, PwdKey string) string
- func DecBase64ByAes(data string, keyText string) []byte
- func Decrypt3DES(src, private []byte) []byte
- func DecryptDES(src, private []byte) []byte
- func Difference(slice1, slice2 []string) []string
- func Dir() (string, error)
- func EnTxtByAes(pwdStr, PwdKey string) string
- func EncBase64ByAes(data string, keyText string) string
- func Encrypt3DES(src []byte, private []byte) []byte
- func EncryptDES(src []byte, private []byte) []byte
- func EnsureDirExist(name string) error
- func Expand(path string) (string, error)
- func FileExists(name string) bool
- func GetMapDefault(k, defaultValue interface{}, m map[interface{}]interface{}) interface{}
- func GetRandomString(length int) string
- func GetSrcZips(src string) ([]string, error)
- func Green(str string, modifier ...interface{}) string
- func GzipCompressFile(srcPath, dstPath string) error
- func HashAndSalt(pwd []byte) string
- func In(haystack interface{}, needle interface{}) (bool, error)
- func InIntSliceMapKeyFunc(haystack []int) func(int) bool
- func InOfInt(obj int, arrayList []int) bool
- func InOfInt32(obj int32, arrayList []int32) bool
- func InOfInt64(obj int64, arrayList []int64) bool
- func InOfStr(str string, arrayList []string) bool
- func InOfType(obj interface{}, arrayList []interface{}, dataType string) bool
- func Intersect(slice1, slice2 []string) []string
- func IsDir(src string) (bool, error)
- func IsFileExist(filePath string) (bool, error)
- func IsZip(src string) (bool, error)
- func JSONMarshalToString(v interface{}) string
- func LightBlue(str string, modifier ...interface{}) string
- func LightCyan(str string, modifier ...interface{}) string
- func LightGray(str string, modifier ...interface{}) string
- func LightGreen(str string, modifier ...interface{}) string
- func LightPurple(str string, modifier ...interface{}) string
- func LightRed(str string, modifier ...interface{}) string
- func MD5Hash(b []byte) string
- func MD5HashString(s string) string
- func MD5HashString16(data string) string
- func Marshal(v interface{}) (string, error)
- func PKCS7Padding(ciphertext []byte, blockSize int) []byte
- func PKCS7UnPadding(origData []byte) ([]byte, error)
- func Pop(haystack interface{}, needle interface{}) (bool, error)
- func PrettyJson(data interface{}) (string, error)
- func Purple(str string, modifier ...interface{}) string
- func RandString(len int) string
- func Red(str string, modifier ...interface{}) string
- func Request(url, method string, param interface{}, headers []map[string]string, ...) ([]byte, error)
- func Reset()
- func SHA1Hash(b []byte) string
- func SHA1HashString(s string) string
- func SHA256Hash(b []byte) string
- func SHA256HashString(s string) string
- func SortInIntSlice(haystack []int, needle int) bool
- func Sum(i []int) int
- func TestAll()
- func UnCompress(src, dst string) error
- func Union(slice1, slice2 []string) []string
- func Unmarshal(s string, v interface{}) error
- func UrlEncode(param map[string]string) string
- func ValidateSaltPasswords(hashedPwd string, plainPwd []byte) bool
- func White(str string, modifier ...interface{}) string
- func Yellow(str string, modifier ...interface{}) string
- type Hash
- type IHash
- type ResponseExec
- type S
- func (s S) Bool() (bool, error)
- func (s S) Bytes() []byte
- func (s S) DefaultBool(defaultVal bool) bool
- func (s S) DefaultFloat32(defaultVal float32) float32
- func (s S) DefaultFloat64(defaultVal float64) float64
- func (s S) DefaultInt(defaultVal int) int
- func (s S) DefaultInt64(defaultVal int64) int64
- func (s S) DefaultUint(defaultVal int) int
- func (s S) DefaultUint64(defaultVal uint64) uint64
- func (s S) Float32() (float32, error)
- func (s S) Float64() (float64, error)
- func (s S) Int() (int, error)
- func (s S) Int64() (int64, error)
- func (s S) JsonToString(v interface{}) error
- func (s S) String() string
- func (s S) Uint() (int, error)
- func (s S) Uint64() (uint64, error)
- type UUID
Constants ¶
const (
ExtZip = ".zip"
)
Variables ¶
var ( JSONMarshal = json.Marshal JSONUnmarshal = json.Unmarshal JSONMarshalIndent = json.MarshalIndent JSONNewDecoder = json.NewDecoder JSONNewEncoder = json.NewEncoder )
定义JSON操作
var DefaultTxtKey = "Ifmkbook1qaz*WSP"
16,24,32位字符串的话,分别对应AES-128,AES-192,AES-256 加密方法 key不能泄露 var PwdKey = []byte("DIS**#KKKDJJSKDI")
var DisableCache bool
DisableCache will disable caching of the home directory. Caching is enabled by default.
Functions ¶
func AesDecrypt ¶ added in v1.10.2
AesDecrypt 实现解密
func AesEncrypt ¶ added in v1.10.2
AesEncrypt 实现加密
func CertInfo ¶ added in v1.0.8
func CertInfo(certPath string, certBytes []byte) (*x509.Certificate, error)
CertInfo "test.pem"
func CurrentUTCTime ¶
func CurrentUTCTime() string
func DeTxtByAes ¶ added in v1.10.2
DeTxtByAes 解密base64 aes
func DecBase64ByAes ¶ added in v1.10.2
DecBase64ByAes Aes + base64 解密
func Dir ¶
Dir returns the home directory for the executing user.
This uses an OS-specific method for discovering the home directory. An error is returned if a home directory cannot be detected.
func EnTxtByAes ¶ added in v1.10.2
EnTxtByAes 加密base64
func EncBase64ByAes ¶ added in v1.10.2
EncBase64ByAes Aes加密 后 base64 再加密
func Encrypt3DES ¶
Encrypt3DES 使用des进行对称加密 length 24
func EncryptDES ¶
EncryptDES 使用des进行对称加密 length 8
func EnsureDirExist ¶
func Expand ¶
Expand expands the path to include the home directory if the path is prefixed with `~`. If it isn't prefixed with `~`, the path is returned as-is.
func FileExists ¶
func GetMapDefault ¶
func GetMapDefault(k, defaultValue interface{}, m map[interface{}]interface{}) interface{}
func GetRandomString ¶
func GetSrcZips ¶ added in v1.0.8
func GzipCompressFile ¶
func HashAndSalt ¶ added in v1.0.8
HashAndSalt Hash & Salt 用户的密码
func InIntSliceMapKeyFunc ¶
func IsFileExist ¶ added in v1.0.8
func JSONMarshalToString ¶
func JSONMarshalToString(v interface{}) string
JSONMarshalToString JSON编码为字符串
func PKCS7Padding ¶ added in v1.10.2
PKCS7Padding PKCS7 填充模式 填充最后一个分组的函数 ciphertext - 原始数据 blockSize - 每个分组的数据长度
func PKCS7UnPadding ¶ added in v1.10.2
PKCS7UnPadding 填充的反向操作,删除填充字符串
func PrettyJson ¶
func RandString ¶
func Reset ¶
func Reset()
Reset clears the cache, forcing the next call to Dir to re-detect the home directory. This generally never has to be called, but can be useful in tests if you're modifying the home directory via the HOME env var or something.
func UnCompress ¶ added in v1.0.8
func ValidateSaltPasswords ¶ added in v1.0.8
ValidateSaltPasswords 验证密码 参数 hashedPwd: Hash & Salt 用户的密码,plainPwd: 明文密码
Types ¶
type ResponseExec ¶ added in v1.0.8
type S ¶
type S string
S 字符串类型转换
func (S) DefaultBool ¶
DefaultBool 转换为bool,如果出现错误则使用默认值
func (S) DefaultFloat32 ¶
DefaultFloat32 转换为float32,如果出现错误则使用默认值
func (S) DefaultFloat64 ¶
DefaultFloat64 转换为float64,如果出现错误则使用默认值
func (S) DefaultInt64 ¶
DefaultInt64 转换为int64,如果出现错误则使用默认值
func (S) DefaultUint64 ¶
DefaultUint64 转换为uint64,如果出现错误则使用默认值
func (S) JsonToString ¶
type UUID ¶
type UUID [16]byte
A UUID is a 128 bit (16 byte) Universal Unique IDentifier as defined in RFC 4122.
var Nil UUID
Nil empty UUID, all zeros
func NewHash ¶
NewHash returns a new UUID derived from the hash of space concatenated with data generated by h. The hash should be at least 16 byte in length. The first 16 bytes of the hash are used to form the UUID. The version of the UUID will be the lower 4 bits of version.
func NewMD5 ¶
NewMD5 returns a new MD5 (Version 3) UUID based on the supplied name space and data. It is the same as calling:
NewHash(md5.New(), space, data, 3)
func NewRandom ¶
NewRandom returns a Random (Version 4) UUID.
The strength of the UUIDs is based on the strength of the crypto/rand package.
A note about uniqueness derived from the UUID Wikipedia entry:
Randomly generated UUIDs have 122 random bits. One's annual risk of being hit by a meteorite is estimated to be one chance in 17 billion, that means the probability is about 0.00000000006 (6 × 10−11), equivalent to the odds of creating a few tens of trillions of UUIDs in a year and having one duplicate.
func NewSHA1 ¶
NewSHA1 returns a new SHA1 (Version 5) UUID based on the supplied name space and data. It is the same as calling:
NewHash(sha1.New(), space, data, 5)