New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose Sha256 algorithm to lua api #14259
Conversation
just a thought as a modder/thinking of the api, as these options are added, potentially more in the future, it seems this would pollute to a degree the minetest api namespace, maybe it would be better to have something like alternatively: |
The latter is the better suggestion, IMO.
(By the way, it should be |
IMO there's no reason or usecase for sha224 and we shouldn't expose it. If we have leftover code we should rather go and remove it. |
while i agree, mainly suggested it that way to keep consistency with |
I'll depend on #14265 as it's likely to be merged before this (that one doesn't add anything, was created by a core dev etc, while this still has no roadmap approval), and that way I'll be able to update the PR for it early... |
@chmodsayshello the PR you mentioned has been merged, feel free to proceed as discussed :) |
bbb204c
to
82275e9
Compare
82275e9
to
27d0de8
Compare
const bool hex = !lua_isboolean(L, 2) || !readParam<bool>(L, 2); | ||
|
||
std::string data_sha256; | ||
data_sha256.assign((char *) SHA256((const unsigned char*) data, size, NULL), SHA256_DIGEST_LENGTH); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If md is NULL, the digest is placed
in a static array. Note: setting md to NULL is not thread safe.
@@ -130,7 +133,6 @@ class ModApiUtil : public ModApiBase | |||
|
|||
// urlencode(value) | |||
static int l_urlencode(lua_State *L); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please keep this space
This is a pull request allowing the sha225 algorithm that already is in minetest's code to be used by mods, which are currently limited to just sha1. This allows mods to hash a given set of data in a more secure way if needed.
This PR Ready for Review.
How to test