maxiaoshan 3 سال پیش
والد
کامیت
03233e7985
1فایلهای تغییر یافته به همراه7 افزوده شده و 0 حذف شده
  1. 7 0
      src/spider/script.go

+ 7 - 0
src/spider/script.go

@@ -733,6 +733,13 @@ func (s *Script) LoadScript(code, script_file string, newstate bool) string {
 		S.Push(lua.LString(result))
 		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
+	}))
 	//长度
 	s.L.SetGlobal("stringLen", s.L.NewFunction(func(S *lua.LState) int {
 		text := S.ToString(-1)