mco_crypt_block
接口适用于实时数据库 RT 。
通过密码密钥字符串准备加密上下文。
void mco_crypt_block(
mco_crypt_ctx_t const* crypt_ctx,
uint1* block,
uint4 block_size,
uint8 block_offs
);
有关概述,请参阅数据库加密页面。
参数
crypt_ctx
mco_crypt_ctx_t const*
已初始化加密上下文的地址。
block
uint1*
要加密的数据数组的地址以及接收加密结果的地址。
block_size
uint4
块大小。
block_offs
uint8
在数据数组中读取或写入块的偏移量。
返回
没有返回值。
示例
/* 基于块的加密代码示例 */
FILE *fin, *fout;
char block[512];
const int block_size = sizeof(block);
const char *cipher = "my cipher key";
mco_crypt_ctx_t crypt_ctx;
size_t n;
uint8 pos = 0;
mco_crypt_init_ctx(&crypt_ctx, cipher);
fin = fopen("unencrypted.file", "rb");
fout = fopen("encrypted.file", "wb");
do
{
n = fread(block, block_size, 1, fin);
mco_crypt_block(&crypt_ctx, block, n, pos);
fwrite(block, n, 1, fout);
pos += block_size;
} while (n == block_size);
fclose(fin);
fclose(fout);
文件
头文件:
mco.h
源文件:
mcocryptaes.c
库:
libmcocryptaes.a
头文件:
mco.h
源文件:
mcocryptstub.c
库:
libmcocryptstub.a