4 Star 10 Fork 7

liudengfeng/xfrpc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
test_fastpbkdf2.c 870 Bytes
一键复制 编辑 原始数据 按行查看 历史
#include <openssl/evp.h>
#include <openssl/sha.h>
#include <string.h>
#include <stdint.h>
#include <stdio.h>
void pbkdf2_key(const uint8_t *password, size_t password_len,
const uint8_t *salt, size_t salt_len,
uint32_t iterations, uint8_t *out, size_t out_len) {
PKCS5_PBKDF2_HMAC((const char *)password, password_len,
salt, salt_len, iterations,
EVP_sha1(), out_len, out);
}
int main() {
const char *password = "password";
const uint8_t salt[] = "saltsalt";
uint8_t key[16]; // size of the derived key
pbkdf2_key((const uint8_t *)password, strlen(password),
salt, sizeof(salt) - 1, 1000, key, sizeof(key));
printf("Derived key: ");
for (size_t i = 0; i < sizeof(key); i++) {
printf("%02x", key[i]);
}
printf("\n");
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/apfree/xfrpc.git
git@gitee.com:apfree/xfrpc.git
apfree
xfrpc
xfrpc
master

搜索帮助