I am using SHA256 to generate hash value in C within a loop, along with the value for which hash is to be generated the counter variable of loop is also passed. As value of counter variable changes in every iteration so I expect SHA256 to return different hash every time. But it returns same hash every time.
Please Help!
Thanks in Advance
Code:
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("
Generating Hash Value ");
hash_value = SHA256(device_info,14,au8HashValue);
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…