paddle_model_decrypt.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #pragma once
  15. #include <stdio.h>
  16. #include <string>
  17. #include "model_deploy/common/include/deploy_declare.h"
  18. // #include "paddle/include/paddle_inference_api.h" // NOLINT
  19. #ifndef PADDLE_MODEL_PROTECT_API_PADDLE_MODEL_DECRYPT_H
  20. #define PADDLE_MODEL_PROTECT_API_PADDLE_MODEL_DECRYPT_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /**
  25. * load (un)encrypted model and params to paddle::AnalysisConfig
  26. * @param config
  27. * @param key 加解密key(注:该SDK能符合的key信息为32字节转为BASE64编码后才能通过)
  28. * @param model_file 模型文件路径
  29. * @param param_file 参数文件路径
  30. * @return error_code
  31. PD_INFER_DECL int paddle_security_load_model(paddle::AnalysisConfig* config,
  32. const char* key,
  33. const char* model_file,
  34. const char* param_file);
  35. */
  36. /**
  37. * check file (un)encrypted?
  38. * @param file_path
  39. * @return
  40. */
  41. PD_INFER_DECL int paddle_check_file_encrypted(const char* file_path);
  42. PD_INFER_DECL std::string decrypt_file(const char* file_path, const char* key);
  43. #ifdef __cplusplus
  44. }
  45. #endif
  46. #endif // PADDLE_MODEL_PROTECT_API_PADDLE_MODEL_DECRYPT_H