我正在使用 SHA256 在循环中生成 C 中的哈希值,以及要为其生成哈希的值,循环的计数器变量也被传递。由于每次迭代中计数器变量的值都会发生变化,所以我希望 SHA256 每次都返回不同的哈希值。但它每次都返回相同的哈希值。请帮忙!
提前致谢
代码:
int generate_sha256hash {
int loop = 0;
unsigned char hash_paramters[2] = {0};
unsigned char device_ids[2] = {0,0};
hash_paramters[0] = 0;
unsigned char pass_string = "PASSWORD";
for(loop = 1; loop < 10; loop++) {
hash_paramters[1] = loop;
memcpy((unsigned char)(&input_info[0]),(unsigned char )hash_paramters ,2);
memcpy((unsigned char)(&input_info[2]),(unsigned char )device_ids,2);
memcpy((unsigned char)(&device_info[4]),(unsigned char*)au8defaultPwd,8);
printf("\n Generating Hash Value ");
hash_value = SHA256(device_info,14,au8HashValue);
}
}