mirror of
https://github.com/vxcontrol/lualibs-md5.git
synced 2026-07-01 06:41:59 -04:00
unimportant
This commit is contained in:
@@ -2,6 +2,12 @@
|
||||
local ffi = require "ffi"
|
||||
local C = ffi.load'md5'
|
||||
|
||||
if not ... then
|
||||
require'md5_test'
|
||||
require'md5_hmac_test'
|
||||
return
|
||||
end
|
||||
|
||||
ffi.cdef[[
|
||||
typedef struct {
|
||||
uint32_t lo, hi;
|
||||
@@ -33,11 +39,16 @@ local function sum(data, size)
|
||||
local d = digest(); d(data, size); return d()
|
||||
end
|
||||
|
||||
if not ... then require'md5_test' end
|
||||
|
||||
return {
|
||||
local md5 = {
|
||||
digest = digest,
|
||||
sum = sum,
|
||||
C = C,
|
||||
}
|
||||
|
||||
function md5.hmac(message, key)
|
||||
local hmac = require'hmac'
|
||||
md5.hmac = hmac.new(sum, 64)
|
||||
return md5.hmac(message, key)
|
||||
end
|
||||
|
||||
return md5
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
local hmac = require'md5'.hmac
|
||||
local glue = require'glue'
|
||||
local unit = require'unit'
|
||||
|
||||
test(glue.tohex(hmac('dude', 'key')), 'e9ecd7d5b2d9dc558d1c2cd173be7c38')
|
||||
test(glue.tohex(hmac('what do ya want for nothing?', 'Jefe')), '750c783e6ab0b503eaa86e310a5db738')
|
||||
Reference in New Issue
Block a user