Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Commit

Permalink
AesEncrypt. In ctor password parameter goes at first.
Browse files Browse the repository at this point in the history
Update doc and examples.
  • Loading branch information
moteus committed Apr 24, 2013
1 parent 6e50e77 commit 4606ea7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

```

12 changes: 6 additions & 6 deletions lua/ZipWriter/encrypt/aes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions utils/mkarch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 4606ea7

Please sign in to comment.