utils

package
v0.0.0-...-7cf6ef0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2018 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Copyright 2018. bolaxy.org authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2018. bolaxy.org authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2018. bolaxy.org authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2018. bolaxy.org authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2018. bolaxy.org authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2018. bolaxy.org authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2018. bolaxy.org authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	AESKEY_LEN_16 = 16
	AESKEY_LEN_24 = 24
	AESKEY_LEN_32 = 32
)

Variables

View Source
var DefaultTimeLoc = time.Local

Functions

func AESCBCDecrypter

func AESCBCDecrypter(data, cbcKey []byte) ([]byte, error)

Decrypter

func AESCBCEncrypter

func AESCBCEncrypter(data, cbcKey []byte) ([]byte, error)

Encrypter

func AbsInt64

func AbsInt64(n int64) int64

int64 a, b |a-b|

func AddFloat64

func AddFloat64(a, b float64) float64

a+b

func Bool

func Bool(f string) (bool, error)

func CompareFloat64

func CompareFloat64(a, b float64) int

比较float64

func ConvertLangTag

func ConvertLangTag(lang string) string

转换语言

func DefaultConfigDir

func DefaultConfigDir() string

func DivFloat64

func DivFloat64(a, b float64) float64

a/b

func EqualFloat64

func EqualFloat64(a, b float64) bool

if a=b

func ExportKey

func ExportKey(key *rsa.PrivateKey) (prvBytes, pybBytes []byte)

func Float32

func Float32(f string) (float32, error)

Float32 string to float32

func Float64

func Float64(f string) (float64, error)

Float64 string to float64

func Format

func Format(str string, size int) string

func GenHashStr

func GenHashStr(msg string) string

生成sha256哈希字符串

func GenRsaKey

func GenRsaKey() *rsa.PrivateKey

func GenerateRandomRsaKeyPair

func GenerateRandomRsaKeyPair() (prvBytes, pubBytes []byte)

func GenerateRandomString

func GenerateRandomString(l int) string

func GetAesKeyRandom

func GetAesKeyRandom(len int) []byte

get aes key random

func GetCurrentDirectory

func GetCurrentDirectory() string

获取当前路径

func GetParentDirectory

func GetParentDirectory(dirctory string) string

获取父级路径

func GetTypeValues

func GetTypeValues(data interface{}) (string, error)

func GreaterThanFloat64

func GreaterThanFloat64(a, b float64) bool

if a>b

func HttpRequest

func HttpRequest(method, urls string, jsonStr string) (r []byte, err error)

发起https请求

func InitLogger

func InitLogger()

func Int

func Int(f string) (int, error)

Int string to int

func Int16

func Int16(f string) (int16, error)

Int16 string to int16

func Int32

func Int32(f string) (int32, error)

Int32 string to int32

func Int64

func Int64(f string) (int64, error)

Int64 string to int64

func Int8

func Int8(f string) (int8, error)

Int8 string to int8

func Interface2Map

func Interface2Map(value interface{}) (map[string]interface{}, error)

func JsonStringToMap

func JsonStringToMap(jstr string) (map[string]interface{}, error)

func LessThanFloat64

func LessThanFloat64(a, b float64) bool

if a<b

func MulFloat64

func MulFloat64(a, b float64) float64

a*b

func PwdSalt

func PwdSalt(pwd string, salt string) string

密码加盐

func RsaDecrypt

func RsaDecrypt(priv, msg []byte) ([]byte, error)

func RsaEncrypt

func RsaEncrypt(pubkey, msg []byte) ([]byte, error)

func RsaSign

func RsaSign(priv, msg []byte) ([]byte, error)

func RsaVerify

func RsaVerify(pubKeyBytes, msg, signature []byte) error

func SortByValue

func SortByValue(info interface{}) []byte

func SortStrByRune

func SortStrByRune(str string) []byte

func SubFloat64

func SubFloat64(a, b float64) float64

a-b

func ToInt64

func ToInt64(value interface{}) (d int64)

ToInt64 interface to int64

func ToStr

func ToStr(value interface{}, args ...int) (s string)

ToStr interface to string

func Uint

func Uint(f string) (uint, error)

Uint string to uint

func Uint16

func Uint16(f string) (uint16, error)

Uint16 string to uint16

func Uint32

func Uint32(f string) (uint32, error)

Uint32 string to uint31

func Uint64

func Uint64(f string) (uint64, error)

Uint64 string to uint64

func Uint8

func Uint8(f string) (uint8, error)

Uint8 string to uint8

func UnitConversion

func UnitConversion(amount float64, factor int64, base int64) (float64, error)

单位换算 amount/(10^factor)

func UnitReConversion

func UnitReConversion(amount float64, factor int64, base int64) (float64, error)

单位反换算 amount*(10^factor)

Types

type CoinStatu

type CoinStatu struct {
	Name     string
	Category int64
	Decimals int64
	Used     bool
}

type FlowOpLogInfo

type FlowOpLogInfo struct {
	ApplyerAccount string
	CaptainId      string
	Option         string
	Opinion        string
	CreateTime     string
}

审批流操作日志详情

type FlowStatus

type FlowStatus struct {
	Hash      string
	Name      string
	AppId     string
	CaptainId string
	Flow      string
	Sign      string
	Status    string
}

type MyMap

type MyMap struct {
	IsUsing map[string]int
	sync.RWMutex
}

func (*MyMap) Get

func (this *MyMap) Get(key string) int

func (*MyMap) Set

func (this *MyMap) Set(key string, value int)

type RPCRsp

type RPCRsp struct {
	RspNo string
}

type ResFlowOpLog

type ResFlowOpLog struct {
	RPCRsp
	HashOperates []FlowOpLogInfo
}

审批流操作日志

type ResHashStatus

type ResHashStatus struct {
	RspNo        string
	Status       ServerStatus
	ApprovalInfo FlowStatus
}

查询审批流上链状态返回值结构

type ServerStatus

type ServerStatus struct {
	ServerStatus    int64
	Status          int64
	Total           int64
	HashCount       int64
	TokenCount      int64
	Address         string
	ContractAddress string
	BtcAddress      string
	CoinStatus      []CoinStatu
}

type TokenInfo

type TokenInfo struct {
	TokenName    string
	Decimals     int64
	ContractAddr string
	Category     int64
}

type VoucherStatus

type VoucherStatus struct {
	RPCRsp
	Status       ServerStatus
	ApprovalInfo FlowStatus
	CoinStatus   []CoinStatu
	TokenInfos   []TokenInfo
}

签名机状态

Jump to

Keyboard shortcuts

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