This is a collection of libraries. It is not intended to be installed by players but instead to be used by other addon developers.
This doesn't serve a direct purpose yet but I'm sure people will find some over time. Possibly for use when sharing serialized content over the wire or with JScanBot for verification of imported/exported content.
Credits
Most of the code for the actual hashing is written by several different people, all mentioned inside the code header of each file. LibMd5 and LibSh1 are MIT licensed, LibSha256 is based on public domain code pieces. I take credit for nothing but the adaption to the Apollo system and the standardization of the public calls between them.
Usage
All libraries are an individually loadable Apollo package provide a :hash() and a :binary() method fo you to call. For easier testing, a GUI has been added. It can be accessed using /libhash or /hash
To use them, you'd add the respective file (i.e. LibSha1.lua) to your toc.xml and then do something like:
local sha1 =Apollo.GetPackage('LibSha1-1').tPackage
local the_hash = sha1:hash('the data')
or similarly
local md5=Apollo.GetPackage('LibMd5-1').tPackage
local the_hash = md5:hash('the data')
or
local sha256 =Apollo.GetPackage('LibSha256-1').tPackage
local the_hash = sha256:hash('the data')
Additionally LibSha1 has an hmac method for signing with a key like so:
local signed_hash = sha1:hmac('secret','the data')
Notes on speed
This is done in pure lua currently, not using the bits32 extension just yet. I would NOT recommend on using them in performance-critical situations at all. The implementation is pretty slow for large data and it doesn't use the lua bit operators yet. A version using much accelerated native calls is on the way but is currently held back because of a bug in the engine's lua interpreter.
Source repository and issue tracker
https://bitbucket.org/vangual/ws-libhash
ToDo
- Make use of the bits32 functions for a speed boost
- Adjust package naming to adhere to the recently introduce namespaces recommendation by drafto.
- Provide HMAC for the rest of the algorithms aswell