Mercurial > prosody-hg
comparison util/hmac.lua @ 1482:9734231a569f
util.hmac: Some optimisations
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sun, 05 Jul 2009 17:10:42 +0100 |
| parents | 6401460891b2 |
| children | 4c9bd0527d1d |
comparison
equal
deleted
inserted
replaced
| 1481:6401460891b2 | 1482:9734231a569f |
|---|---|
| 1 local hashes = require "util.hashes" | 1 local hashes = require "util.hashes" |
| 2 local xor = require "bit".bxor | 2 local xor = require "bit".bxor |
| 3 | |
| 4 local t_insert, t_concat = table.insert, table.concat; | |
| 5 local s_char = string.char; | |
| 3 | 6 |
| 4 module "hmac" | 7 module "hmac" |
| 5 | 8 |
| 6 local function arraystr(array) | 9 local function arraystr(array) |
| 7 local t = {} | 10 local t = {} |
| 8 for i = 1,table.getn(array) do | 11 for i = 1,#array do |
| 9 table.insert(t, string.char(array[i])) | 12 t_insert(t, s_char(array[i])) |
| 10 end | 13 end |
| 11 | 14 |
| 12 return table.concat(t) | 15 return t_concat(t) |
| 13 end | 16 end |
| 14 | 17 |
| 15 --[[ | 18 --[[ |
| 16 key | 19 key |
| 17 the key to use in the hash | 20 the key to use in the hash |
