Skip to content

Commit b9708f5

Browse files
committed
更新sql
1 parent 4a33390 commit b9708f5

File tree

3 files changed

+3005
-77
lines changed

3 files changed

+3005
-77
lines changed

configuration.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"User" : "root",
88
"Password" : "test1234",
99
"Charset" : "utf8",
10-
"SQLLog" : true, /*是否输出SQL*/
10+
"SQLLog" : false, /*是否输出SQL*/
1111
"URL" : "", /*数据库连接地址*/
1212
"MaxIdleConns" : 5, /*空闲时最大的连接数*/
1313
"MaxOpenConns" : 10 /*最大的连接数*/

go/utils/security.go

+20-17
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,28 @@ func DecodeWeAppUserInfo(encryptedData string, sessionKey string, iv string) (st
2828
}
2929

3030
result, resultErr := AESDecrypt(cipher, key, theIV)
31-
resultStr := string(result)
32-
fmt.Println(resultStr)
33-
return string(result), resultErr
31+
if resultErr != nil {
32+
return "", resultErr
33+
}
34+
return string(result), nil
3435
}
3536

36-
func AESDecrypt(ciphertext, key, iv []byte) ([]byte, error) {
37-
block, err := aes.NewCipher(key) //选择加密算法
38-
if err != nil {
39-
return nil, err
40-
}
41-
blockModel := cipher.NewCBCDecrypter(block, iv)
42-
plantText := make([]byte, len(ciphertext))
43-
blockModel.CryptBlocks(plantText, ciphertext)
44-
plantText = PKCS7UnPadding(plantText, block.BlockSize())
45-
return plantText, nil
37+
// AESDecrypt AES解密
38+
func AESDecrypt(cipherBytes, key, iv []byte) ([]byte, error) {
39+
block, err := aes.NewCipher(key)
40+
if err != nil {
41+
return nil, err
42+
}
43+
blockModel := cipher.NewCBCDecrypter(block, iv)
44+
dst := make([]byte, len(cipherBytes))
45+
blockModel.CryptBlocks(dst, cipherBytes)
46+
dst = PKCS7UnPadding(dst, block.BlockSize())
47+
return dst, nil
4648
}
4749

48-
func PKCS7UnPadding(plantText []byte, blockSize int) []byte {
49-
length := len(plantText)
50-
unpadding := int(plantText[length-1])
51-
return plantText[:(length - unpadding)]
50+
// PKCS7UnPadding pkcs7填充方式
51+
func PKCS7UnPadding(dst []byte, blockSize int) []byte {
52+
length := len(dst)
53+
unpadding := int(dst[length - 1])
54+
return dst[:(length - unpadding)]
5255
}

0 commit comments

Comments
 (0)