添加代码
This commit is contained in:
26
util.go
Normal file
26
util.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"github.com/dop251/goja"
|
||||
)
|
||||
|
||||
//go:embed des.js
|
||||
var des string
|
||||
|
||||
func strEnc(data string) string {
|
||||
vm := goja.New()
|
||||
_, err := vm.RunString(des)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
sum, ok := goja.AssertFunction(vm.Get("strEnc"))
|
||||
if !ok {
|
||||
panic("Not a function")
|
||||
}
|
||||
res, err := sum(goja.Undefined(), vm.ToValue(data), vm.ToValue("1"), vm.ToValue("2"), vm.ToValue("3"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return res.String()
|
||||
}
|
||||
Reference in New Issue
Block a user