Skip to content

Commit

Permalink
exposed make hash to lua
Browse files Browse the repository at this point in the history
Signed-off-by: nicol-ii <[email protected]>
  • Loading branch information
nicol-ii committed Jan 22, 2025
1 parent 485e175 commit eee148e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/parsec/agent/runners/lua/impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,15 +315,14 @@ namespace cbdc::parsec::agent::runner {
size_t sz{};
const auto* str = lua_tolstring(L, 1, &sz);
assert(str != nullptr);
// compute hash
auto sha = CSHA256();
auto unsigned_str = std::vector<unsigned char>(sz);
std::memcpy(unsigned_str.data(), str, sz);
sha.Write(unsigned_str.data(), sz);
cbdc::hash_t computed_hash{};
sha.Finalize(computed_hash.data());
lua_pushlstring(L, reinterpret_cast<char*>(computed_hash.data()), sz);
return 0;
return 1;
}

}

0 comments on commit eee148e

Please sign in to comment.