paddle_model_encrypt.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #pragma once
  2. #include <iostream>
  3. #ifndef PADDLE_MODEL_PROTECT_API_PADDLE_MODEL_ENCRYPT_H
  4. #define PADDLE_MODEL_PROTECT_API_PADDLE_MODEL_ENCRYPT_H
  5. #ifdef WIN32
  6. #ifdef PM_EXPORTS
  7. #define PDE_MODEL_API __declspec(dllexport)
  8. #else
  9. #define PDE_MODEL_API __declspec(dllimport)
  10. #endif
  11. #endif
  12. #ifdef linux
  13. #define PDE_MODEL_API __attribute__((visibility("default")))
  14. #endif
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. /**
  19. * generate random key
  20. * 产生随机的 key 信息,如果想要使用当前 SDK,
  21. * 对于传入的key信息有要求(需符合产生32字节随机值后做 BASE64 编码
  22. * @return
  23. */
  24. PDE_MODEL_API std::string paddle_generate_random_key();
  25. /**
  26. * encrypt __model__, __params__ files in src_dir to dst_dir
  27. * @param keydata
  28. * @param src_dir
  29. * @param dst_dir
  30. * @return
  31. */
  32. PDE_MODEL_API int paddle_encrypt_dir(const char* keydata, const char* src_dir, const char* dst_dir);
  33. /**
  34. * encrypt file
  35. * @param keydata 可使用由 paddle_generate_random_key 接口产生的key,也可以根据规则自己生成
  36. * @param infile
  37. * @param outfile
  38. * @return error_code
  39. */
  40. PDE_MODEL_API int paddle_encrypt_model(const char* keydata, const char* infile, const char* outfile);
  41. PDE_MODEL_API int encrypt_stream(const std::string &keydata, std::istream &in_stream, std::ostream &out_stream);
  42. #ifdef __cplusplus
  43. }
  44. #endif
  45. #endif //PADDLE_MODEL_PROTECT_API_PADDLE_MODEL_ENCRYPT_H