コンテンツにスキップ

ハッシュ関数

暗号学的ハッシュ関数とHMACメッセージ認証を提供します。

local hash = require("hash")
local hex = hash.md5("data")
local raw = hash.md5("data", true)
パラメータ説明
datastringハッシュするデータ
rawboolean?hexの代わりに生バイトを返す

戻り値: string, error

local hex = hash.sha1("data")
local raw = hash.sha1("data", true)
パラメータ説明
datastringハッシュするデータ
rawboolean?hexの代わりに生バイトを返す

戻り値: string, error

local hex = hash.sha256("data")
local raw = hash.sha256("data", true)
パラメータ説明
datastringハッシュするデータ
rawboolean?hexの代わりに生バイトを返す

戻り値: string, error

local hex = hash.sha512("data")
local raw = hash.sha512("data", true)
パラメータ説明
datastringハッシュするデータ
rawboolean?hexの代わりに生バイトを返す

戻り値: string, error

local hex = hash.hmac_md5("message", "secret")
local raw = hash.hmac_md5("message", "secret", true)
パラメータ説明
datastring認証するメッセージ
secretstring秘密鍵
rawboolean?hexの代わりに生バイトを返す

戻り値: string, error

local hex = hash.hmac_sha1("message", "secret")
local raw = hash.hmac_sha1("message", "secret", true)
パラメータ説明
datastring認証するメッセージ
secretstring秘密鍵
rawboolean?hexの代わりに生バイトを返す

戻り値: string, error

local hex = hash.hmac_sha256("message", "secret")
local raw = hash.hmac_sha256("message", "secret", true)
パラメータ説明
datastring認証するメッセージ
secretstring秘密鍵
rawboolean?hexの代わりに生バイトを返す

戻り値: string, error

local hex = hash.hmac_sha512("message", "secret")
local raw = hash.hmac_sha512("message", "secret", true)
パラメータ説明
datastring認証するメッセージ
secretstring秘密鍵
rawboolean?hexの代わりに生バイトを返す

戻り値: string, error

ハッシュテーブルとパーティショニング用の高速ハッシュです。

local n = hash.fnv32("data")
パラメータ説明
datastringハッシュするデータ

戻り値: number, error

衝突を減らすための大きな出力を持つ高速ハッシュです。

local n = hash.fnv64("data")
パラメータ説明
datastringハッシュするデータ

戻り値: number, error

条件種別再試行可能
入力が文字列でないerrors.INVALIDno
シークレットが文字列でない(HMAC)errors.INVALIDno

エラーの処理についてはエラー処理を参照。