utils

package
Version: v0.0.0-...-6dbf283 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2015 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendSalt

func AppendSalt(src, salt []byte) []byte

func Csha512

func Csha512(d string, p []byte) (bool, error)

func Equal

func Equal(src []byte, dst []byte) bool

func FromBase64

func FromBase64(src string) ([]byte, error)

func FromBits

func FromBits(data []byte, obj interface{}) error

func FromHex

func FromHex(s string) ([]byte, error)

func FromJson

func FromJson(j []byte, o interface{}) error

func FromToml

func FromToml(f string, v interface{}) error

func FuncName

func FuncName(f interface{}) string

func Md5

func Md5(p []byte) string

func Mkdirs

func Mkdirs(d string, m os.FileMode) error

func OpenRedisPool

func OpenRedisPool(host string, port, db int) *redis.Pool

func ParseSalt

func ParseSalt(src []byte, length int) ([]byte, []byte)

func PkgRoot

func PkgRoot(o interface{}) string

func RandomBytes

func RandomBytes(size int) ([]byte, error)

func Sha512

func Sha512(p []byte) string

func Shell

func Shell(cmd string, args ...string) error

func Ssha512

func Ssha512(p []byte, l int) (string, error)

func ToBase64

func ToBase64(src []byte) string

func ToBits

func ToBits(obj interface{}) ([]byte, error)

func ToHex

func ToHex(bs []byte) string

func ToJson

func ToJson(o interface{}) ([]byte, error)

func ToToml

func ToToml(f string, v interface{}) error

func Uuid

func Uuid() string

Types

type Aes

type Aes struct {
	//16、24或者32位的[]byte,分别对应AES-128, AES-192或AES-256算法
	Cip cipher.Block `inject:"aes.cipher"`
}

func (*Aes) Decrypt

func (p *Aes) Decrypt(sr []byte) ([]byte, error)

func (*Aes) Encrypt

func (p *Aes) Encrypt(pn []byte) ([]byte, error)

type Hmac

type Hmac struct {
	Key []byte           `inject:"hmac.key"` //32 bits
	Fn  func() hash.Hash `inject:"hmac.fn"`
}

func (*Hmac) Equal

func (p *Hmac) Equal(src, dst []byte) bool

func (*Hmac) Sum

func (p *Hmac) Sum(src []byte) []byte

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL