diff options
author | Matthew Wild <mwild1@gmail.com> | 2008-10-24 07:34:13 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2008-10-24 07:34:13 +0100 |
commit | d49ea8a12e4440a0df267b575e4925231bda4803 (patch) | |
tree | 490259090b642a38634973be5ed4d8d42ec500d1 /util/hashes.lua | |
parent | 1d1e9fba5745958c092d28563970f1acb4ee4604 (diff) | |
download | prosody-d49ea8a12e4440a0df267b575e4925231bda4803.tar.gz prosody-d49ea8a12e4440a0df267b575e4925231bda4803.zip |
Partial s2s commit
Diffstat (limited to 'util/hashes.lua')
-rw-r--r-- | util/hashes.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/util/hashes.lua b/util/hashes.lua new file mode 100644 index 00000000..64374a8f --- /dev/null +++ b/util/hashes.lua @@ -0,0 +1,27 @@ + +local softreq = function (...) return select(2, pcall(require, ...)); end + +module "hashes" + +local md5 = softreq("md5"); +if md5 then + if md5.digest then + local md5_digest = md5.digest; + local sha1_digest = sha1.digest; + function _M.md5(input) + return md5_digest(input); + end + function _M.sha1(input) + return sha1_digest(input); + end + elseif md5.sumhexa then + local md5_sumhexa = md5.sumhexa; + function _M.md5(input) + return md5_sumhexa(input); + end + else + error("md5 library found, but unrecognised... no hash functions will be available", 0); + end +end + +return _M; |