paddle_model_decrypt.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #pragma once
  2. #include <stdio.h>
  3. #include "paddle_inference_api.h"
  4. #ifndef PADDLE_MODEL_PROTECT_API_PADDLE_MODEL_DECRYPT_H
  5. #define PADDLE_MODEL_PROTECT_API_PADDLE_MODEL_DECRYPT_H
  6. #ifdef WIN32
  7. #ifdef PM_EXPORTS
  8. #define PDD_MODEL_API __declspec(dllexport)
  9. #else
  10. #define PDD_MODEL_API __declspec(dllimport)
  11. #endif
  12. #endif
  13. #ifdef linux
  14. #define PDD_MODEL_API __attribute__((visibility("default")))
  15. #endif
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. /**
  20. * load (un)encrypted model and params to paddle::AnalysisConfig
  21. * @param config
  22. * @param key 加解密key(注:该SDK能符合的key信息为32字节转为BASE64编码后才能通过)
  23. * @param model_file 模型文件路径
  24. * @param param_file 参数文件路径
  25. * @return error_code
  26. */
  27. PDD_MODEL_API int paddle_security_load_model(paddle::AnalysisConfig* config,
  28. const char* key,
  29. const char* model_file,
  30. const char* param_file);
  31. /**
  32. * check file (un)encrypted?
  33. * @param file_path
  34. * @return
  35. */
  36. PDD_MODEL_API int paddle_check_file_encrypted(const char* file_path);
  37. PDD_MODEL_API std::string decrypt_file(const char* file_path, const char* key);
  38. #ifdef __cplusplus
  39. }
  40. #endif
  41. #endif //PADDLE_MODEL_PROTECT_API_PADDLE_MODEL_DECRYPT_H