增加限制条件

This commit is contained in:
hoteas
2022-05-06 13:08:13 +08:00
parent 4cbc84063a
commit 25ab6c219d
3 changed files with 17 additions and 2 deletions
+13 -1
View File
@@ -2,10 +2,12 @@ package app
import (
"bytes"
"code.hoteas.com/golang/hotime/common"
"crypto/aes"
"crypto/cipher"
"encoding/base64"
"errors"
"fmt"
)
//高级加密标准(Adevanced Encryption Standard ,AES
@@ -56,12 +58,21 @@ func AesEcrypt(origData []byte, key []byte) ([]byte, error) {
}
//实现解密
func AesDeCrypt(cypted []byte, key []byte) ([]byte, error) {
func AesDeCrypt(cypted []byte, key []byte) (bytes []byte, err error) {
//异常处理
defer func() {
if e := recover(); e != nil {
//that.SetError(errors.New(fmt.Sprint(err)), LOG_FMT)
fmt.Println(err)
err = errors.New(common.ObjToStr(e))
}
}()
//创建加密算法实例
block, err := aes.NewCipher(key)
if err != nil {
return nil, err
}
//获取块大小
blockSize := block.BlockSize()
//创建加密客户端实例
@@ -91,6 +102,7 @@ func DePwdCode(pwd string) ([]byte, error) {
//解密base64字符串
pwdByte, err := base64.StdEncoding.DecodeString(pwd)
if err != nil {
fmt.Println(err)
return nil, err
}
//执行AES解密
+1
View File
@@ -44,6 +44,7 @@ var UpanCtr = Ctr{
re, e := DePwdCode(sn)
if e != nil {
fmt.Println(e)
that.Display(3, "数据异常")
return
}