| 165 | } |
| 166 | |
| 167 | void init_hash(nb::module_& m) { |
| 168 | m.def("hash", nb::overload_cast<const Object&>(&hash)); |
| 169 | m.def("hash", nb::overload_cast<const std::vector<uint8_t>&>(&hash)); |
| 170 | m.def("hash", |
| 171 | [] (nb::bytes bytes) { |
| 172 | const auto* begin = reinterpret_cast<const uint8_t*>(bytes.c_str()); |
| 173 | const auto* end = begin + bytes.size(); |
| 174 | return LIEF::hash(std::vector<uint8_t>(begin, end)); |
| 175 | }); |
| 176 | |
| 177 | m.def("hash", |
| 178 | [] (const std::string& bytes) { |
| 179 | const std::vector<uint8_t> data = {std::begin(bytes), std::end(bytes)}; |
| 180 | return hash(data); |
| 181 | }); |
| 182 | } |
| 183 | |
| 184 | |
| 185 | void init_json(nb::module_& m) { |