diff --git a/README.md b/README.md index 48b90e0..440db6b 100644 --- a/README.md +++ b/README.md @@ -71,3 +71,17 @@ FTP.get{ ZipStream:close() ``` + +Make encrypted archive +```lua +local ZipWriter = require"ZipWriter" +local AesEncrypt = require"ZipWriter.encrypt.aes" + +ZipStream = ZipWriter.new{ + encrypt = AesEncrypt.new('password') +} + +-- as before + +``` + diff --git a/lua/ZipWriter/encrypt/aes.lua b/lua/ZipWriter/encrypt/aes.lua index 3b25e9f..ff51d14 100644 --- a/lua/ZipWriter/encrypt/aes.lua +++ b/lua/ZipWriter/encrypt/aes.lua @@ -293,13 +293,13 @@ local ZIP_AES_MODES = { [AES_MODE.AES256] = 256, } -function AesEncrypt:new(mode, password) +function AesEncrypt:new(password, mode) local salt, version - if type(mode) == 'table' then - password = mode.password - version = mode.version - salt = mode.salt - mode = mode.mode + if type(password) == 'table' then + version = password.version + salt = password.salt + mode = password.mode + password = password.password end local o = setmetatable({}, self) diff --git a/utils/mkarch.lua b/utils/mkarch.lua index 3f7267b..6c45fcc 100644 --- a/utils/mkarch.lua +++ b/utils/mkarch.lua @@ -2,8 +2,6 @@ local IS_WINDOWS = package.config:sub(1,1) == '\\' local ZipWriter = require "ZipWriter" local PATH = require "path" -PATH.findfile = require "path.findfile" -local lfs = require "lfs" local TEXT_EXT = {".lua", ".txt", ".c", ".cpp", ".h", ".hpp", ".pas", ".cxx", ".me"} @@ -65,10 +63,10 @@ if PATH.extension(oFile):lower() ~= '.zip' then end local files = {} -for fullpath in PATH.findfile(mask,{recurse = true;skipdirs = false}) do +PATH.each(mask, function(fullpath) local relpath = string.sub(fullpath, #base + 1) table.insert(files,{fullpath, relpath}) -end +end,{recurse=true;skipdirs=true}) writer = ZipWriter.new{ level = ZipWriter.COMPRESSION_LEVEL.DEFAULT;