You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -49,8 +50,8 @@ See file "sha2_test.lua" for more examples.
49
50
***Q:** Does this module calculate SHA2 really fast?
50
51
***A:**
51
52
Probably, this is the fastest pure Lua implementation of SHA2 you can find.
52
-
For example, on x64 Lua 5.3 this module calculates SHA256 twice as fast as the implementation published at [lua-users.org](http://lua-users.org/wiki/SecureHashAlgorithmBw)
53
-
This module has best performance on every Lua version because it contains several version-specific implementation branches:
53
+
For example, on x64 Lua 5.3 this module calculates SHA256 twice as fast as the implementation published at [lua-users.org](http://lua-users.org/wiki/SecureHashAlgorithmBw)
54
+
This module has best performance on every Lua version because it contains several version-specific implementation branches:
54
55
- branch for **Lua 5.1** (emulating bitwise operators using look-up table)
55
56
- branch for **Lua 5.2** (using **bit32** library), suitable also for **Lua 5.1** with external **bit** library
Copy file name to clipboardExpand all lines: sha2_test.lua
+29-2Lines changed: 29 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -23,9 +23,9 @@ local function test_sha256()
23
23
append_next_chunk(" jumps ")
24
24
append_next_chunk("") -- chunk may be an empty string
25
25
append_next_chunk("over the lazy dog")
26
-
assert(append_next_chunk() =="d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592") -- invocation without an argument means "give me the final result"
26
+
assert(append_next_chunk() =="d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592") -- invocation without an argument means "give me the result"
27
27
assert(append_next_chunk() =="d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592") -- you can ask the same result multiple times if needed
28
-
assert(notpcall(append_next_chunk, "more text")) -- no more chunks are allowed after receiving the final result, append_next_chunk("more text") will fail
28
+
assert(notpcall(append_next_chunk, "more text")) -- no more chunks are allowed after receiving the result, append_next_chunk("more text") will fail
29
29
30
30
-- one-liner is possible due to "append_next_chunk(chunk)" returns the function "append_next_chunk"
31
31
assert(sha256()("The quick brown fox")(" jumps ")("")("over the lazy dog")() =="d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592")
0 commit comments