From 467f30efb648eaf23bb604f00a087bbfb93254b5 Mon Sep 17 00:00:00 2001 From: Pedro Gimeno Date: Sat, 2 Jul 2016 10:42:54 +0200 Subject: [PATCH 1/5] Add large strings test to demonstrate failure in current version. --- spec/md5_spec.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/spec/md5_spec.lua b/spec/md5_spec.lua index ed00a0e..929770d 100644 --- a/spec/md5_spec.lua +++ b/spec/md5_spec.lua @@ -15,16 +15,20 @@ describe('md5', function() assert.equal(md5.sumhexa('The quick brown fox jumps over the lazy dog.'), 'e4d909c290d0fb1ca068ffaddf22cbd0') assert.equal(md5.sumhexa(''), 'd41d8cd98f00b204e9800998ecf8427e') assert.equal(md5.sumhexa(('1'):rep(824)), 'a126fd3611ab8d9b7e8a3384e2fa78a0') + assert.equal(md5.sumhexa(('1'):rep(1528)), '3750b6a29d923b633e05d6ae76895664') + assert.equal(md5.sumhexa(('1'):rep(99999)), '3b527ec3aa350362ab2eca64c94cfc6d') end) end) describe('md5.sum', function() it('works', function() assert.equal(md5.sum("asdf"), hex2bin '912ec803b2ce49e4a541068d495ab570') - assert.equal(md5.sum('The quick brown fox jumps over the lazy dog'), hex2bin'9e107d9d372bb6826bd81d3542a419d6') - assert.equal(md5.sum('The quick brown fox jumps over the lazy dog.'), hex2bin'e4d909c290d0fb1ca068ffaddf22cbd0') - assert.equal(md5.sum(''), hex2bin'd41d8cd98f00b204e9800998ecf8427e') - assert.equal(md5.sum(('1'):rep(824)), hex2bin'a126fd3611ab8d9b7e8a3384e2fa78a0') + assert.equal(md5.sum('The quick brown fox jumps over the lazy dog'), hex2bin '9e107d9d372bb6826bd81d3542a419d6') + assert.equal(md5.sum('The quick brown fox jumps over the lazy dog.'), hex2bin 'e4d909c290d0fb1ca068ffaddf22cbd0') + assert.equal(md5.sum(''), hex2bin 'd41d8cd98f00b204e9800998ecf8427e') + assert.equal(md5.sum(('1'):rep(824)), hex2bin 'a126fd3611ab8d9b7e8a3384e2fa78a0') + assert.equal(md5.sum(('1'):rep(1528)), hex2bin '3750b6a29d923b633e05d6ae76895664') + assert.equal(md5.sum(('1'):rep(99999)), hex2bin '3b527ec3aa350362ab2eca64c94cfc6d') end) end) end) From dd10f1c9defd3d51cbda70a174145fd2ce66732f Mon Sep 17 00:00:00 2001 From: Pedro Gimeno Date: Sat, 2 Jul 2016 10:44:35 +0200 Subject: [PATCH 2/5] Fix #4 by limiting the sum output to 32 bits. --- md5.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/md5.lua b/md5.lua index 4a9e721..8ae63a1 100644 --- a/md5.lua +++ b/md5.lua @@ -346,7 +346,8 @@ local function transform(A,B,C,D,X) c=z(i,c,d,a,b,X[ 2],15,t[63]) b=z(i,b,c,d,a,X[ 9],21,t[64]) - return A+a,B+b,C+c,D+d + return bit_and(A+a,0xFFFFFFFF),bit_and(B+b,0xFFFFFFFF), + bit_and(C+c,0xFFFFFFFF),bit_and(D+d,0xFFFFFFFF) end ---------------------------------------------------------------- From 7e5623a206631183de8d99bb617d34c8cf26c9b0 Mon Sep 17 00:00:00 2001 From: kikito Date: Sat, 2 Jul 2016 18:22:53 +0200 Subject: [PATCH 3/5] luacheck install fix --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 53998d6..15b3875 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ before_install: - export PATH=$PATH:$PWD/lua_install/bin # Add directory with all installed binaries to PATH install: - - luarocks install luacheck + - luarocks install luacheck --deps-mode=none - luarocks install busted - luarocks install luacov - luarocks install luacov-coveralls From 8603af5e23497b97105c6d4d65f3c4c7b8fb8d81 Mon Sep 17 00:00:00 2001 From: kikito Date: Sat, 2 Jul 2016 18:32:44 +0200 Subject: [PATCH 4/5] delete long example which is too slow in lua 5.1 --- spec/md5_spec.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/spec/md5_spec.lua b/spec/md5_spec.lua index 929770d..8425c95 100644 --- a/spec/md5_spec.lua +++ b/spec/md5_spec.lua @@ -16,7 +16,6 @@ describe('md5', function() assert.equal(md5.sumhexa(''), 'd41d8cd98f00b204e9800998ecf8427e') assert.equal(md5.sumhexa(('1'):rep(824)), 'a126fd3611ab8d9b7e8a3384e2fa78a0') assert.equal(md5.sumhexa(('1'):rep(1528)), '3750b6a29d923b633e05d6ae76895664') - assert.equal(md5.sumhexa(('1'):rep(99999)), '3b527ec3aa350362ab2eca64c94cfc6d') end) end) @@ -28,7 +27,6 @@ describe('md5', function() assert.equal(md5.sum(''), hex2bin 'd41d8cd98f00b204e9800998ecf8427e') assert.equal(md5.sum(('1'):rep(824)), hex2bin 'a126fd3611ab8d9b7e8a3384e2fa78a0') assert.equal(md5.sum(('1'):rep(1528)), hex2bin '3750b6a29d923b633e05d6ae76895664') - assert.equal(md5.sum(('1'):rep(99999)), hex2bin '3b527ec3aa350362ab2eca64c94cfc6d') end) end) end) From 5297100c7cbd7b6609c487750e44fcf8707e99cc Mon Sep 17 00:00:00 2001 From: kikito Date: Sat, 2 Jul 2016 19:08:52 +0200 Subject: [PATCH 5/5] luacheck install fix remove luacheck --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 15b3875..90bd434 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,13 +14,11 @@ before_install: - export PATH=$PATH:$PWD/lua_install/bin # Add directory with all installed binaries to PATH install: - - luarocks install luacheck --deps-mode=none - luarocks install busted - luarocks install luacov - luarocks install luacov-coveralls script: - - luacheck --no-unused-args --std max+busted *.lua spec - busted --verbose --coverage after_success: