浏览代码

公共方法新增转base64

maxiaoshan 3 年之前
父节点
当前提交
3f26cccce4
共有 2 个文件被更改,包括 8 次插入1 次删除
  1. 7 0
      src/spider/script.go
  2. 1 1
      src/timetask/timetask.go

+ 7 - 0
src/spider/script.go

@@ -410,6 +410,13 @@ func (s *Script) LoadScript(downloadnode, script string, isfile ...string) {
 		S.Push(lua.LBool(ok))
 		return 1
 	}))
+	//base64加密
+	s.L.SetGlobal("encodeBase64", s.L.NewFunction(func(S *lua.LState) int {
+		text := S.ToString(-1)
+		base64Text := base64.StdEncoding.EncodeToString([]byte(text))
+		S.Push(lua.LString(base64Text))
+		return 1
+	}))
 	//aes ecb模式加密
 	s.L.SetGlobal("aesEncryptECB", s.L.NewFunction(func(S *lua.LState) int {
 		origData := S.ToString(-2)

+ 1 - 1
src/timetask/timetask.go

@@ -189,7 +189,7 @@ func UpdateCodeHeart() {
 	defer qu.Catch()
 	query := map[string]interface{}{
 		"state": map[string]interface{}{
-			"$in": []int{4, 6, 7, 8, 9, 10},
+			"$in": []int{4, 6, 7, 8, 9, 10, 11},
 		},
 	}
 	list, _ := util.MgoE.Find("luaconfig", query, nil, map[string]interface{}{"code": 1}, false, -1, -1)