Resource icon

[Open Assets] Bastardized SHA-1 and HMAC-SHA1 Routines in Pure Lua 2021-04-24

What permissions do you give others to modify and/or maintain your submission?
Modify: YES - Maintain: YES - I give permission for my entire submission to be modified by others or used in their own work. I give permission for my entire submission to be maintained by others as well.
Borrowed from this blog post:
http://regex.info/blog/lua/sha1

Updated to fit the constraints of SRB2. - Ie. Bastardized*
This is more of a utility WAD than anything.

Utilize Lua's asserts to verify your sha1 or hmac_sha1 text hashes.
Pass sha1() a string, and it returns a hash as a 40-character hex string. For example, calling the following:
Code:
local hash = sha1("test")

puts the 40-character string into the hash variable
Code:
"ad620dece3f62045f3e0b236220c68b94c935a34"

Pass sha1_hmac() a key and a message, and it returns the signature as a 40-byte hex string.

There are also 2 "*_binary" versions which do the same, but return the 20-byte string of raw data that the 40-byte hex strings represent.

DISCLAIMER:
* This is a bastardized version of SHA-1 and HMAC-SHA1 routines. Meaning that these SHA1 and HMAC-SHA1 routines are only compatible with checking hashes within SRB2 itself. Actual SHA1 and HMAC-SHA1 routines will give different results.
With the the lack of math.modf Library, measurements are done with the FRACUNIT (65536) unit of measurement instead.

Supporters / CoAuthors

Author
Flame
Downloads
284
Views
881
Extension type
wad
File size
109.6 KB
MD5 Hash
d791191919cc9e1e7ba9fa97978da553
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from Flame

Share this resource

Back
Top