crypto

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2023 License: BSD-3-Clause Imports: 4 Imported by: 10

README

crypto GoDoc

Functions

  • md5(string) - return md5 checksum from string.
  • sha256(string) - return sha256 checksum from string.

Examples

local crypto = require("crypto")

-- md5
if not(crypto.md5("1\n") == "b026324c6904b2a9cb4b88d6d61c81d1") then
    error("md5")
end

-- sha256
if not(crypto.sha256("1\n") == "4355a46b19d348dc2f57c046f8ef63d4538ebb936000f3c9ee954a27460dd865") then
    error("sha256")
end

Documentation

Overview

Package crypto implements golang package crypto functionality for lua.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Loader

func Loader(L *lua.LState) int

Loader is the module loader function.

func MD5

func MD5(L *lua.LState) int

MD5 lua crypto.md5(string) return string

Example

crypto.md5(string)

state := lua.NewState()
Preload(state)
source := `
    local crypto = require("crypto")
    print(crypto.md5("1\n"))
`
if err := state.DoString(source); err != nil {
	log.Fatal(err.Error())
}
Output:

b026324c6904b2a9cb4b88d6d61c81d1

func Preload

func Preload(L *lua.LState)

Preload adds crypto to the given Lua state's package.preload table. After it has been preloaded, it can be loaded using require:

local crypto = require("crypto")

func SHA256

func SHA256(L *lua.LState) int

SHA256 lua crypto.sha256(string) return string

Example

crypto.sha256(string)

state := lua.NewState()
Preload(state)
source := `
    local crypto = require("crypto")
    print(crypto.sha256("1\n"))
`
if err := state.DoString(source); err != nil {
	log.Fatal(err.Error())
}
Output:

4355a46b19d348dc2f57c046f8ef63d4538ebb936000f3c9ee954a27460dd865

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL