Created by: Yanghello
Required(必填, multiple choices, two at most) PR type(PR 类型) is (A ): A. New features(新功能)---------------- D. Performance optimization(性能优化) B. Bug fixes(问题修复)------------------ E. Breaking changes(向后不兼容的改变) C. Function optimization(功能优化)------F. Others(其它)
PR changes(改动点)is (D): A. OPs(operators)---------------------- C. Docs(文档) ### B. APIs(接口)--------------------------- D. Others(其它)
Use one sentence to describe what this PR does.(简述本次PR的目的和改动)
增加两对易于使用的加解密接口,用于对数据机密性有要求的使用场景,比如加密保存模型、参数、变量等。(resolve #24693 (closed))
Optional(选填, If None, please delete it) Describe what this PR does in detail. If this PR fixes an issue, please give the issue id. 此feature主要提供给用Python端的接口,此pr目前是C++代码,下一个PR将提交Python代码。 对于此PR中的C++接口,使用步骤如下: 1、创建配置文件,配置加密算法参数(使用默认算法时,可以不创建),如config_file可以如下:
cipher_name : AES_CRT_NoPadding
tag_size : 128
iv_size : 128
2、生成加密Cipher
std::string key = CipherUtils::GenKey(256);
/ /产生密钥
auto cipher = CipherFactory::CreateCipher("config_file");
// 不输入参数时则使用默认配置
3、加密 "hello world"
std::string ciphertext = cipher->Encrypt("hello world", input_key);
4、解密
std::string plaintext = cipher->Decrypt(ciphertext, input_key);