utils

package
v0.0.0-...-e1989bb Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2021 License: GPL-2.0 Imports: 27 Imported by: 0

Documentation

Overview

**************************************************

** @Desc : This file for AES/ECB/PKCS5Padding
** @Time : 2019.04.09 16:25
** @Author : Joker
** @File : aes_ecb_v1
** @Last Modified by : Joker
** @Last Modified time: 2019.04.09 16:25
** @Software: GoLand

***************************************************

**************************************************

** @Desc : This file for 加密、解密方法
** @Time : 2018.12.28 14:10
** @Author : Joker
** @File : encryption
** @Last Modified by : Joker
** @Last Modified time: 2019-4-8 09:54:58
** @Software: GoLand

***************************************************

**************************************************

** @Desc : This file for 共有方法
** @Time : 2019.04.01 11:48
** @Author : Joker
** @File : global_method
** @Last Modified by : Joker
** @Last Modified time: 2019.04.01 11:48
** @Software: GoLand

***************************************************

**************************************************

** @Desc : This file for 发送短信验证码
** @Time : 2019.04.04 9:37
** @Author : Joker
** @File : send_messages
** @Last Modified by : Joker
** @Last Modified time: 2019.04.04 9:37
** @Software: GoLand

***************************************************

**************************************************

** @Desc : This file for 字符串常量
** @Time : 2019.04.01 11:45
** @Author : Joker
** @File : strings
** @Last Modified by : Joker
** @Last Modified time: 2019.04.01 11:45
** @Software: GoLand

***************************************************

**************************************************

** @Desc : This file for ...
** @Time : 2019.04.03 18:01
** @Author : Joker
** @File : template
** @Last Modified by : Joker
** @Last Modified time: 2019.04.03 18:01
** @Software: GoLand

***************************************************

Index

Constants

View Source
const (
	APIKEY     = "fd264aa****"
	TPL1       = 2512750
	URLSENDSMS = "https://sms.yunpian.com/v2/sms/tpl_single_send.json"
)

短信配置

View Source
const (
	TPL2   = 2453286
	MOBILE = "18670135299"
)

提现成功接收短信通知

View Source
const (
	FAILED_FLAG    = -9
	FAILED_STRING  = "操作失败! "
	SUCCESS_FLAG   = 9
	SUCCESS_STRING = "操作成功! "
)

成功与否的标记

View Source
const (
	STARTKEY = "\n-----BEGIN PUBLIC KEY-----\n"
	ENDKEY   = "\n-----END PUBLIC KEY-----"
)

秘钥头尾

View Source
const (
	I = "I"
	S = "S"
	F = "F"
)

订单状态

View Source
const (
	A = "a" //对接
	P = "p" //平台
)

订单类别

View Source
const (
	SingleMaxForPay      = 45000
	SingleMaxForTransfer = 20000
	SingleMinForRecharge = 20
)
View Source
const UPASSWORD = "tcp@143258"

用户登录默认密码

View Source
const (
	XF = "XF"
)

通道类型

Variables

This section is empty.

Functions

func GetApiOrderStatus

func GetApiOrderStatus() map[string]string

func GetChannelType

func GetChannelType() map[string]string

func GetOrderStatus

func GetOrderStatus() map[string]string

func NewECBDecrypter

func NewECBDecrypter(b cipher.Block) cipher.BlockMode

NewECBDecrypter returns a BlockMode which decrypts in electronic code book mode, using the given Block.

func NewECBEncrypter

func NewECBEncrypter(b cipher.Block) cipher.BlockMode

NewECBEncrypter returns a BlockMode which encrypts in electronic code book mode, using the given Block.

Types

type AES

type AES struct{}

func (*AES) AesDecrypt

func (the *AES) AesDecrypt(crypted, key []byte) ([]byte, error)

解密

func (*AES) AesDecryptV2

func (the *AES) AesDecryptV2(crypted, key []byte) ([]byte, error)

解密 5.0.0版本

func (*AES) AesEncrypt

func (the *AES) AesEncrypt(src, key string) (string, error)

加密

func (*AES) AesEncryptV2

func (the *AES) AesEncryptV2(src, key string) (string, error)

加密 5.0.0版本

func (*AES) PKCS5Padding

func (*AES) PKCS5Padding(ciphertext []byte, blockSize int) []byte

func (*AES) PKCS5UnPadding

func (*AES) PKCS5UnPadding(origData []byte) []byte

type Encrypt

type Encrypt struct{}

func (*Encrypt) Base64Decode

func (*Encrypt) Base64Decode(raw string) ([]byte, error)

base64解码

func (*Encrypt) Base64Encode

func (*Encrypt) Base64Encode(raw []byte) string

base64编码

func (*Encrypt) EncodeMd5

func (*Encrypt) EncodeMd5(buf []byte) string

将字符串加密成 md5

func (*Encrypt) RsaDecrypto

func (*Encrypt) RsaDecrypto(keyText, privateKey []byte) ([]byte, error)

RSA解密

func (*Encrypt) RsaEncrypto

func (*Encrypt) RsaEncrypto(origData, publicKey []byte) ([]byte, error)

RSA加密

func (*Encrypt) SHA256WithRSAToSign

func (*Encrypt) SHA256WithRSAToSign(originalData, privateKey []byte) ([]byte, error)

SHA256WithRSA生成签名

type GlobalMethod

type GlobalMethod struct{}

func (*GlobalMethod) GbkToUtf8

func (*GlobalMethod) GbkToUtf8(s []byte) ([]byte, error)

gbk转为utf-8

func (*GlobalMethod) GetDatabaseStatus

func (*GlobalMethod) GetDatabaseStatus(code int) map[string]interface{}

返回当前操作数据库的状态:成功/失败

func (*GlobalMethod) GetNowTime

func (*GlobalMethod) GetNowTime() string

返回当前时间的字符串:2006-01-02 15:04:05

func (*GlobalMethod) GetNowTimeV2

func (*GlobalMethod) GetNowTimeV2() string

返回当前时间的字符串:20060102150405

func (*GlobalMethod) GetNowTimeV3

func (*GlobalMethod) GetNowTimeV3() string

返回当前时间的字符串:2006-01-02

func (*GlobalMethod) JsonFormat

func (*GlobalMethod) JsonFormat(code int, data interface{}, msg string, url string) (json map[string]interface{})

* * @Description: 返回当前操作数据库的状态 * @Author: Joker * @Date: 2019.04.01 14:37 * @Param: code: 状态码,msg; 状态信息:url: 跳转地址; data: json内容 * @return: 返回Json串 *

func (*GlobalMethod) LoginPasswordSolt

func (*GlobalMethod) LoginPasswordSolt(pwd, salt string) string

* * @Description: 登录密码加盐 * @Author: Joker * @Date: 2019.04.01 11:49 * @Param: pwd: 原始密码 * @Param: salt: 盐值 * @return: hash *

func (*GlobalMethod) MoneyFenToYuan

func (*GlobalMethod) MoneyFenToYuan(fen string) (float64, bool)

* * @Description: 金额分转化为元 * @Author: Joker * @Date: 2019.04.10 9:20 * @Param: fen: 分 * @return: float64: 元; bool:false: 转化没有错误 *

func (*GlobalMethod) MoneyYuanToFen

func (*GlobalMethod) MoneyYuanToFen(yuan float64) (string, bool)

* * @Description: 金额元转化为分 * @Author: Joker * @Date: 2019.04.10 9:19 * @Param: yuan: 元 * @return: string: 分; bool: true:转化没有错误 *

func (*GlobalMethod) MoneyYuanToFloat

func (*GlobalMethod) MoneyYuanToFloat(yuan string) (float64, error)

func (*GlobalMethod) MoneyYuanToString

func (*GlobalMethod) MoneyYuanToString(yuan float64) string

func (*GlobalMethod) PasswordSolt

func (this *GlobalMethod) PasswordSolt(pwd string) (string, string)

* * @Description: 注册密码加盐 * @Author: Joker * @Date: 2019.04.01 11:48 * @Param: pwd: 原始密码 * @return: 返回hash和盐 *

func (*GlobalMethod) RandIpAddr

func (*GlobalMethod) RandIpAddr() (ip string)

生成随机IP

func (*GlobalMethod) RandomIntOfString

func (*GlobalMethod) RandomIntOfString(length int) string

生成n位随机数字字符串

func (*GlobalMethod) RandomString

func (*GlobalMethod) RandomString(length int) string

在数字、大写字母、小写字母范围内生成num位的随机字符串

func (*GlobalMethod) StructToMap

func (*GlobalMethod) StructToMap(s interface{}) map[string]string

struct to map

func (*GlobalMethod) ToStringByMap

func (*GlobalMethod) ToStringByMap(m map[string]string) (s string)

将map拼接成字符串,去掉最后一个&符号

func (*GlobalMethod) UrlEncode

func (*GlobalMethod) UrlEncode(m map[string]string) string

type SendMessages

type SendMessages struct{}

func (*SendMessages) SendSmsCode

func (*SendMessages) SendSmsCode(mobile, code string) bool

发送验证码

func (*SendMessages) SendSmsForPay

func (*SendMessages) SendSmsForPay(mobile, code string) bool

发送提现通知

type Template

type Template struct{}

func (*Template) IfOr

func (*Template) IfOr(r int) bool

if多条件判断 管理员权限控制

func (*Template) IfOrB2C

func (*Template) IfOrB2C(r int) bool

VIP用户权限控制

func (*Template) Yuan2

func (*Template) Yuan2(yuan float64) string

Directories

Path Synopsis
**************************************************
**************************************************

Jump to

Keyboard shortcuts

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