在go中使用lua示例, 基于gopher-lua!
Nelze vybrat více než 25 témat
Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
|
package crypto
|
|
|
|
import (
|
|
"crypto/md5"
|
|
"crypto/sha256"
|
|
"fmt"
|
|
|
|
lua "github.com/yuin/gopher-lua"
|
|
)
|
|
|
|
func MD5(L *lua.LState) int {
|
|
str := L.CheckString(1)
|
|
hash := md5.Sum([]byte(str))
|
|
L.Push(lua.LString(fmt.Sprintf("%x", hash)))
|
|
return 1
|
|
}
|
|
|
|
func SHA256(L *lua.LState) int {
|
|
str := L.CheckString(1)
|
|
hash := sha256.Sum256([]byte(str))
|
|
L.Push(lua.LString(fmt.Sprintf("%x", hash)))
|
|
return 1
|
|
}
|