Skip to content

Commit

Permalink
docs(usage) fix m_cost description and provide better examples
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaultcha committed Dec 6, 2016
1 parent a2ad1c5 commit 961ea4a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

### Added

- :stars: Support for Argon2_id encoding variant.
- :stars: Support for Argon2id encoding variant.
[#24](https://github.com/thibaultcha/lua-argon2/pull/24)
- We now automatically compute the length of the retrieved encoded hash from
`encrypt()`. [#21](https://github.com/thibaultcha/lua-argon2/pull/21)
Expand Down Expand Up @@ -78,7 +78,7 @@

Initial release with support for Argon2
[20151206](https://github.com/P-H-C/phc-winner-argon2/releases/tag/20151206).
Implement a C bridge for Argon2_i and Argon2_d encoding and a
Implement a C bridge for Argon2i and Argon2d encoding and a
Lua module for input validation.

[unreleased]: https://github.com/thibaultcha/lua-argon2/compare/3.0.0...master
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ local encoded = assert(argon2.encrypt("password", "somesalt", {
-- Hashing options
local encoded = assert(argon2.encrypt("password", "somesalt", {
t_cost = 4,
m_cost = 16,
m_cost = math.pow(2, 16), -- 65536 KiB
parallelism = 2
}))
-- encoded is "$argon2i$v=19$m=16,t=4,p=2$c29tZXNhbHQ$zeUdR8y+Dqo4B5gDTYJzYVlJjVeg2rY5Le1/pp/wdVQ"
-- encoded is "$argon2i$v=19$m=65536,t=4,p=2$c29tZXNhbHQ$n6x5DKNWV8BOeKemQJRk7BU3hcaCVomtn9TCyEA0inM"

-- Changing the default options (those arguments are the current defaults)
argon2.t_cost(3)
Expand Down
9 changes: 6 additions & 3 deletions src/argon2.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ Default values of this module can be overriden with `m_cost()`, `t_cost()`,
argon2.encrypt("password", "salt", { t_cost = 4 })
Can be set to a new default in lua-argon2 (C binding only) by calling:
argon2.t_cost(4)
@field m_cost Sets memory usage to 2^N KiB (`number`, default: `12`).
argon2.encrypt("password", "salt", { m_cost = 16 })
@field m_cost Sets memory usage as KiB (`number`, default: `12`).
argon2.encrypt("password", "salt", {
m_cost = math.pow(2, 16) -- 2^16 aka 65536 KiB
})
Can be set to a new default in lua-argon2 (C binding only) by calling:
argon2.m_cost(16)
@field parallelism Number of threads and compute lanes (`number`, default: `1`).
Expand Down Expand Up @@ -234,9 +236,10 @@ if err then
error("could not encrypt: " .. err)
end
-- with options
-- with options and variant
local hash, err = argon2.encrypt("password", "somesalt", {
t_cost = 4,
m_cost = math.pow(2, 16), -- 65536 KiB
variant = argon2.variants.argon2_d
})
*/
Expand Down

0 comments on commit 961ea4a

Please sign in to comment.