I have a value stored as an unsigned char *. It holds the SHA1 hash of a string. Since I'm using <openssl/evp.h>
to generate the hashes, I end up with an unsigned char*
holding the SHA1 value.
Now I want to iterate from a value until the end of the SHA1 image space. So if the value was a decimal int I would iterate with i = <original_value>
and i++
till I reach the max possible value of the image space.
How do I do this over an unsigned char *
value?
I am assuming your pointer refers to 20 bytes, for the 160 bit value. (An alternative may be text characters representing hex values for the same 160 bit meaning, but occupying more characters)
You can declare a class for the data, and implement a method to increment the low order unsigned byte, test it for zero, and if zero, increment the next higher order byte, and so on.