Software /
code /
prosody
Comparison
util/hashes.lua @ 148:4c0dcd245d34 s2s
s2s works! \o/ \o/
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 24 Oct 2008 07:27:36 +0100 |
child | 155:8c9a9f6f6455 |
comparison
equal
deleted
inserted
replaced
147:ccebb2720741 | 148:4c0dcd245d34 |
---|---|
1 | |
2 local softreq = function (...) return select(2, pcall(require, ...)); end | |
3 | |
4 module "hashes" | |
5 | |
6 local md5 = softreq("md5"); | |
7 if md5 then | |
8 if md5.digest then | |
9 local md5_digest = md5.digest; | |
10 local sha1_digest = sha1.digest; | |
11 function _M.md5(input) | |
12 return md5_digest(input); | |
13 end | |
14 function _M.sha1(input) | |
15 return sha1_digest(input); | |
16 end | |
17 elseif md5.sumhexa then | |
18 local md5_sumhexa = md5.sumhexa; | |
19 function _M.md5(input) | |
20 return md5_sumhexa(input); | |
21 end | |
22 else | |
23 error("md5 library found, but unrecognised... no hash functions will be available", 0); | |
24 end | |
25 end | |
26 | |
27 return _M; |