MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / decrypt_model

Function decrypt_model

lite/example/cpp_example/mge/user_cryption.cpp:8–22  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6
7namespace {
8std::vector<uint8_t> decrypt_model(
9 const void* model_mem, size_t size, const std::vector<uint8_t>& key) {
10 if (key.size() == 1) {
11 std::vector<uint8_t> ret(size, 0);
12 const uint8_t* ptr = static_cast<const uint8_t*>(model_mem);
13 uint8_t key_data = key[0];
14 for (size_t i = 0; i < size; i++) {
15 ret[i] = ptr[i] ^ key_data ^ key_data;
16 }
17 return ret;
18 } else {
19 printf("the user define decrypt method key length is wrong.\n");
20 return {};
21 }
22}
23
24bool register_cryption_method(const Args& args) {
25 std::string network_path = args.model_path;

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected