From 9ba182d65c5b035617b1d10e6b5e4be5ae1a0f22 Mon Sep 17 00:00:00 2001 From: hoteas <等> Date: Fri, 6 May 2022 13:08:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=99=90=E5=88=B6=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code.go | 4 +++- example/app/AES.go | 14 +++++++++++++- example/app/upan.go | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/code.go b/code.go index bbdbce1..2e9134b 100644 --- a/code.go +++ b/code.go @@ -44,7 +44,9 @@ var TptProject = Proj{ } link := strings.Replace(column.GetString("name"), "_id", "", -1) - + if link == "parent" { + link = that.RouterString[1] + } re[link] = that.Db.Get(column.GetString("link"), seStr, Map{"id": v}) } } diff --git a/example/app/AES.go b/example/app/AES.go index 72b8510..a90b7eb 100644 --- a/example/app/AES.go +++ b/example/app/AES.go @@ -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解密 diff --git a/example/app/upan.go b/example/app/upan.go index 76ea011..beb1d93 100644 --- a/example/app/upan.go +++ b/example/app/upan.go @@ -44,6 +44,7 @@ var UpanCtr = Ctr{ re, e := DePwdCode(sn) if e != nil { + fmt.Println(e) that.Display(3, "数据异常") return }