Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encryption #4

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions deserialize_chunk.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ local param1, param2, node_data

-- deserializes the chunk to the world
function mapsync.deserialize_chunk(chunk_pos, filename, vmanip)
-- TODO: check for key.json
-- mapsync.parse_chunk_key(filename)
-- if encrypted: decrypt if key available or move to pending queue
local chunk, err_msg = mapsync.parse_chunk(filename)
if not chunk then
return false, err_msg
Expand Down
15 changes: 12 additions & 3 deletions serialize_chunk.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ function mapsync.serialize_chunk(chunk_pos, filename)
return true
end

-- get key manifest from zip before overwriting
local key_manifest = mapsync.parse_chunk_key(filename)

-- open zip for writing
local f = global_env.io.open(filename, "wb")
if not f then
Expand Down Expand Up @@ -92,9 +95,15 @@ function mapsync.serialize_chunk(chunk_pos, filename)
end
end

zip:add("mapdata.bin", table.concat(mapdata))
zip:add("metadata.json", minetest.write_json(metadata))
zip:add("manifest.json", minetest.write_json(manifest))
if key_manifest then
-- encrypt and add key manifest
-- TODO
else
-- store plain
zip:add("mapdata.bin", table.concat(mapdata))
zip:add("metadata.json", minetest.write_json(metadata))
zip:add("manifest.json", minetest.write_json(manifest))
end

zip:close()
f:close()
Expand Down
Loading