github.com/treeverse/lakefs@v1.24.1-0.20240520134607-95648127bfb0/pkg/actions/lua/crypto/md5/md5.go (about) 1 package md5 2 3 import ( 4 "crypto/md5" //#nosec 5 "fmt" 6 7 "github.com/Shopify/go-lua" 8 ) 9 10 func Open(l *lua.State) { 11 md5Open := func(l *lua.State) int { 12 lua.NewLibrary(l, md5Library) 13 return 1 14 } 15 lua.Require(l, "crypto/md5", md5Open, false) 16 l.Pop(1) 17 } 18 19 var md5Library = []lua.RegistryFunction{ 20 {Name: "digest", Function: digest}, 21 } 22 23 func digest(l *lua.State) int { 24 data := lua.CheckString(l, 1) 25 sum := md5.Sum([]byte(data)) //#nosec 26 l.PushString(fmt.Sprintf("%x", sum)) 27 return 1 28 }