<stdio.h> #include <openssl/bn.h> int main() { BIGNUM *bn; bn = BN_new(); //生成一个BIGNUM结构 int bits = 20; int top = -1; int bottom = 1; BN_rand(bn, bits, top, bottom); //生成指定bits的随机数 char *a = BN_bn2hex(bn); //转化成16进制字符串 puts(a); BN_free(bn); //释放BIGNUM结构 return 0; }

实验效果:

# ./a.out 
062FAF

相关文章:

猜你喜欢
  • 2022-12-23
  • 2021-11-30
  • 2021-11-04
相关资源
相似解决方案