algoutil

package
v0.0.0-...-c5f9841 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2018 License: MIT Imports: 31 Imported by: 0

Documentation

Overview

Package algoutil contain some scaffold algo

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccessControl

func AccessControl(h http.Handler) http.Handler

func CallSite

func CallSite() interface{}

CallSite the caller's file & line

func ConcatWithURLEncode

func ConcatWithURLEncode(params map[string]string) *bytes.Buffer

func CopyDir

func CopyDir(dst string, src string) error

func CopyFile

func CopyFile(dst, src string) error

func FileExists

func FileExists(path string) bool

func GenRSAKey

func GenRSAKey() (privateKey, publicKey string, err error)

GenRSAKey gen a rsa key pair, the bit size is 512

func HTTPGet

func HTTPGet(url string) (string, error)

HTTPGet http's get method

func LoadPrivateKey

func LoadPrivateKey(privKeyPath string) (*rsa.PrivateKey, error)

func MD5

func MD5(plain []byte) []byte

MD5 md5 digest

func MD5String

func MD5String(plain string) string

MD5String md5 digest in string

func MakeDirIfNeed

func MakeDirIfNeed(dir string, mode os.FileMode) error

func OptionControl

func OptionControl(h http.Handler) http.Handler

func ParamsToStruct

func ParamsToStruct(params string, v interface{}) error

TODO: WARNING!!!!!!! All struct field must be string type

func ParseParams

func ParseParams(params string) map[string]string

func ParsePrivateKey

func ParsePrivateKey(data []byte) (*rsa.PrivateKey, error)

func PasswordHash

func PasswordHash(pwd string) (hash, salt string)

PasswordHash accept password and generate with uuid as salt FORMAT: sha1.Sum(pwd + salt + sha1.Sum(salt + pwd + salt) + salt + pwd)

func RSADecrypt

func RSADecrypt(cipher []byte, privKey string) ([]byte, error)

RsaDecrypt decrypt data by rsa

func RSAEncrypt

func RSAEncrypt(plain []byte, pubKey string) ([]byte, error)

RSAEncrypt encrypt data by rsa

func RandStr

func RandStr(strlen int) string

生成随机字符串

func RetriveInt64OrDefault

func RetriveInt64OrDefault(s string, d int64) int64

func RetriveIntOrDefault

func RetriveIntOrDefault(s string, d int) int

func RunCmd

func RunCmd(cmdName string, workingDir string, args ...string) (string, error)

func Sign

func Sign(plain []byte, privKey string) (string, error)

Sign with database appsecret string(base64 encode)

func SortAndConcat

func SortAndConcat(params map[string]string, extras ...bool) []byte

SortAndConcat sort the map by key in ASCII order, and concat it in form of "k1=v1&k2=v2"

func SortParams

func SortParams(m map[string]string) string

func TimeRange

func TimeRange(start, end int64) (int64, int64)

TimeRange adjust the time range.

func Unused

func Unused(args ...interface{})

func Utf8ToGBK

func Utf8ToGBK(utf8str string) string

func Verify

func Verify(pubKey string, data []byte, sign string) error

Verify with database appkey string(base64 encode)

func VerifyPassword

func VerifyPassword(pwd, salt, hash string) bool

func VerifyRSAWithMD5

func VerifyRSAWithMD5(pubKey string, data []byte, sign string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL