aboutsummaryrefslogtreecommitdiffstats
path: root/util/hashes.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2008-10-24 07:27:36 +0100
committerMatthew Wild <mwild1@gmail.com>2008-10-24 07:27:36 +0100
commit5c90ffdf7e7c7d784ed5f60eed3f8a2666c117f8 (patch)
tree00c7446dee596c9f5a2559a3e26109687e640669 /util/hashes.lua
parent5031be1f8cb3a5a8785c07c5e4c5802913c209f6 (diff)
downloadprosody-5c90ffdf7e7c7d784ed5f60eed3f8a2666c117f8.tar.gz
prosody-5c90ffdf7e7c7d784ed5f60eed3f8a2666c117f8.zip
s2s works! \o/ \o/
Diffstat (limited to 'util/hashes.lua')
-rw-r--r--util/hashes.lua27
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;