|
@@ -928,6 +928,32 @@ func (s *Script) LoadScript(site, channel, user *string, code, script_file strin
|
|
S.Push(lua.LString(result))
|
|
S.Push(lua.LString(result))
|
|
return 1
|
|
return 1
|
|
}))
|
|
}))
|
|
|
|
+ //aes cbc模式加密
|
|
|
|
+ s.L.SetGlobal("aesEncryptCBC", s.L.NewFunction(func(S *lua.LState) int {
|
|
|
|
+ origData := S.ToString(-3)
|
|
|
|
+ key := S.ToString(-2)
|
|
|
|
+ iv := S.ToString(-1)
|
|
|
|
+ bytekey := []byte(key)
|
|
|
|
+ byteorigData := []byte(origData)
|
|
|
|
+ byteiv := []byte(iv)
|
|
|
|
+ encrypted := util.AesCBCEncrypt(byteorigData, bytekey, byteiv)
|
|
|
|
+ // 将加密后的数据和初始向量进行Base64编码
|
|
|
|
+ result := base64.StdEncoding.EncodeToString(encrypted)
|
|
|
|
+ S.Push(lua.LString(result))
|
|
|
|
+ return 1
|
|
|
|
+ }))
|
|
|
|
+ //aes cbc模式解密
|
|
|
|
+ s.L.SetGlobal("aesDecryptCBC", s.L.NewFunction(func(S *lua.LState) int {
|
|
|
|
+ origData := S.ToString(-3)
|
|
|
|
+ key := S.ToString(-2)
|
|
|
|
+ iv := S.ToString(-1)
|
|
|
|
+ bytekey := []byte(key)
|
|
|
|
+ byteiv := []byte(iv)
|
|
|
|
+ data, _ := base64.StdEncoding.DecodeString(origData)
|
|
|
|
+ result := util.AesCBCDecrypter(data, bytekey, byteiv)
|
|
|
|
+ S.Push(lua.LString(result))
|
|
|
|
+ return 1
|
|
|
|
+ }))
|
|
//aes ecb模式加密
|
|
//aes ecb模式加密
|
|
s.L.SetGlobal("aesEncryptECB", s.L.NewFunction(func(S *lua.LState) int {
|
|
s.L.SetGlobal("aesEncryptECB", s.L.NewFunction(func(S *lua.LState) int {
|
|
origData := S.ToString(-2)
|
|
origData := S.ToString(-2)
|
|
@@ -966,6 +992,31 @@ func (s *Script) LoadScript(site, channel, user *string, code, script_file strin
|
|
S.Push(lua.LString(result))
|
|
S.Push(lua.LString(result))
|
|
return 1
|
|
return 1
|
|
}))
|
|
}))
|
|
|
|
+ //des cbc模式加密
|
|
|
|
+ s.L.SetGlobal("desEncryptCBC", s.L.NewFunction(func(S *lua.LState) int {
|
|
|
|
+ origData := S.ToString(-3)
|
|
|
|
+ key := S.ToString(-2)
|
|
|
|
+ iv := S.ToString(-1)
|
|
|
|
+ bytekey := []byte(key)
|
|
|
|
+ byteorigData := []byte(origData)
|
|
|
|
+ byteiv := []byte(iv)
|
|
|
|
+ encrypted := util.DesCBCEncrypt(byteorigData, bytekey, byteiv)
|
|
|
|
+ result := base64.StdEncoding.EncodeToString(encrypted)
|
|
|
|
+ S.Push(lua.LString(result))
|
|
|
|
+ return 1
|
|
|
|
+ }))
|
|
|
|
+ //des cbc模式解密
|
|
|
|
+ s.L.SetGlobal("desDecryptCBC", s.L.NewFunction(func(S *lua.LState) int {
|
|
|
|
+ origData := S.ToString(-3)
|
|
|
|
+ key := S.ToString(-2)
|
|
|
|
+ iv := S.ToString(-1)
|
|
|
|
+ bytekey := []byte(key)
|
|
|
|
+ byteiv := []byte(iv)
|
|
|
|
+ data, _ := base64.StdEncoding.DecodeString(origData)
|
|
|
|
+ result := util.DesCBCDecrypter(data, bytekey, byteiv)
|
|
|
|
+ S.Push(lua.LString(result))
|
|
|
|
+ return 1
|
|
|
|
+ }))
|
|
//rsa 公钥加密
|
|
//rsa 公钥加密
|
|
s.L.SetGlobal("rsaEncrypt", s.L.NewFunction(func(S *lua.LState) int {
|
|
s.L.SetGlobal("rsaEncrypt", s.L.NewFunction(func(S *lua.LState) int {
|
|
origData := S.ToString(-2)
|
|
origData := S.ToString(-2)
|