Documentation
¶
Overview ¶
Package scripthash is the hashing a managed script is given, as a Starlark module (#2049).
It is separate from the engine for the reason internal/scriptdate is: every function is a pure transformation of its arguments, there is no run, no caller and no state, and the engine's only use of it is to predeclare the module. A digest is deterministic, so a recorded run replays with nothing recorded for it.
Index ¶
Constants ¶
const Name = "hash"
Name is the global the module is bound to.
Variables ¶
var Module = &module{members: starlark.StringDict{ "md5": digestBuiltin("md5", md5.New), "sha1": digestBuiltin("sha1", sha1.New), "sha256": digestBuiltin("sha256", sha256.New), "sha512": digestBuiltin("sha512", sha512.New), "hmac_sha1": hmacBuiltin("hmac_sha1", sha1.New), "hmac_sha256": hmacBuiltin("hmac_sha256", sha256.New), "hmac_sha512": hmacBuiltin("hmac_sha512", sha512.New), "crc32": starlark.NewBuiltin(Name+".crc32", crc32Fn), "fnv64": starlark.NewBuiltin(Name+".fnv64", fnv64Fn), }}
Module is the hash module the engine predeclares.
Every digest is computed in Go, so hashing a value costs one step whatever its length: an MD5 written in Starlark spends a step per operation and a megabyte page alone exhausts a run's step budget.
The module is also callable. Starlark's universe has hash(x), and the module takes its name, so hash("abc") keeps returning what the universe's hash returned before the module existed.
Functions ¶
This section is empty.
Types ¶
This section is empty.