19 lines
546 B
Lua
19 lines
546 B
Lua
-- hashText.lua -- tiny hashing tool: write text to a temp file, read it back,
|
|
-- and print its SHA-256, SHA-1, and byte length, then clean up.
|
|
-- run: bin/calog examples/scripts/apps/hashText.lua
|
|
|
|
local path = "/tmp/hashText-" .. tostring(timeNow()) .. ".txt"
|
|
local text = "The quick brown fox jumps over the lazy dog"
|
|
|
|
fsWrite(path, text)
|
|
|
|
local data = fsRead(path)
|
|
|
|
calogPrint("path: ", path)
|
|
calogPrint("bytes: ", #data)
|
|
calogPrint("sha256:", cryptoHashSha256(data))
|
|
calogPrint("sha1: ", cryptoHashSha1(data))
|
|
|
|
fsRemove(path)
|
|
|
|
calogExit(0)
|