summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Ipsum <richard.ipsum@codethink.co.uk>2014-01-21 12:47:50 +0000
committerRichard Ipsum <richard.ipsum@codethink.co.uk>2014-02-12 14:46:14 +0000
commit0e129b4a48912197f63a7bea91cd60c0a96e8fdb (patch)
tree150f2bbc173a6359c7c57ef7a3a73f2df85a93f4
parentc5c86235cd7616939dad1bac086e958c1f7529ff (diff)
downloadgitano-0e129b4a48912197f63a7bea91cd60c0a96e8fdb.tar.gz
Add hash_password and check_password to util
-rw-r--r--lib/gitano/util.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/gitano/util.lua b/lib/gitano/util.lua
index 51c5bc2..c2a53a7 100644
--- a/lib/gitano/util.lua
+++ b/lib/gitano/util.lua
@@ -9,9 +9,20 @@
local luxio = require 'luxio'
local sio = require 'luxio.simple'
local log = require 'gitano.log'
+local scrypt = require 'scrypt'
local tconcat = table.concat
+local check_password = scrypt.verify_password
+
+local function hash_password(password)
+ -- For the moment we are using scrypt,
+ -- we may decide to use other hash functions in the future
+ -- so it's useful to provide some way to identify which hash
+ -- function was used
+ return 'scrypt', scrypt.hash_password(password, 2^14, 8, 1)
+end
+
local function _deep_copy(t, memo)
if not memo then memo = {} end
if memo[t] then return memo[t] end
@@ -480,4 +491,7 @@ return {
process_expansion = process_expansion,
set = set,
+
+ hash_password = hash_password,
+ check_password = check_password,
}