Add crypto.lua: hash_file + hash_string via sha256sum #8

Closed
opened 2026-03-17 16:09:45 +01:00 by michael · 1 comment
Owner

Add src/daw/lua/common/crypto.lua with file and string hashing via sha256sum.

Functions

-- Returns "sha256:<hex>", nil | nil, err_string
M.hash_file(path)
M.hash_string(s)

Implementation notes

  • Both via io.popen() + sha256sum (POSIX, no external deps)
  • hash_string: uses echo -n to avoid trailing newline
  • Output format: "sha256:" .. hex (consistent with transaction_context hashes{})
  • Follows pattern of time.lua, yaml.lua

Deliverables

  • src/daw/lua/common/crypto.lua
  • test/test_crypto.lua
  • Makefile + README updated

References

Add `src/daw/lua/common/crypto.lua` with file and string hashing via `sha256sum`. ## Functions ```lua -- Returns "sha256:<hex>", nil | nil, err_string M.hash_file(path) M.hash_string(s) ``` ## Implementation notes - Both via `io.popen()` + `sha256sum` (POSIX, no external deps) - `hash_string`: uses `echo -n` to avoid trailing newline - Output format: `"sha256:" .. hex` (consistent with transaction_context hashes{}) - Follows pattern of `time.lua`, `yaml.lua` ## Deliverables - `src/daw/lua/common/crypto.lua` - `test/test_crypto.lua` - Makefile + README updated ## References - DAW/steurjan#16 (first consumer: document_hash) - DAW/daw-lua-common#7 (ext split context)
Author
Owner

Implementation: add get_raw() to http_client.lua

Needed by DAW/steurjan#16 (invoiceninja PDF download).
Without get_raw(), http_client always runs json.decode() on the response --
binary data (PDFs) comes back as a table instead of raw bytes.

Change: add M.get_raw(url, headers) -- same pattern as M.get() but skips
json.decode, returns raw string directly.

Consumers update accordingly:

  • src/adapters/invoice/invoiceninja/http.lua: get_raw() delegates to http_client.get_raw()
  • socket.http + ltn12 imports removed from http.lua (back to common-only)
Implementation: add get_raw() to http_client.lua Needed by DAW/steurjan#16 (invoiceninja PDF download). Without get_raw(), http_client always runs json.decode() on the response -- binary data (PDFs) comes back as a table instead of raw bytes. Change: add M.get_raw(url, headers) -- same pattern as M.get() but skips json.decode, returns raw string directly. Consumers update accordingly: - src/adapters/invoice/invoiceninja/http.lua: get_raw() delegates to http_client.get_raw() - socket.http + ltn12 imports removed from http.lua (back to common-only)
michael 2026-03-18 14:00:45 +01:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DAW/daw-lua-common#8
No description provided.