Part - I : All Possible Combinations
I am pretty sure its hexadecimal property makes it limited to a number of possible combinations. I have made an excel which will describe this number. I guess searching the number online can also give the same results.
A short heads up : SHA will have 64 characters length as shown in the picture below. I am calling it
Master Seed[Hypothetical] where all the characters are "0" which is nothing but
singularity. A seed where no hexadecimal is there,
it's just start point for our reference. I'm assuming you're trying to find SHA256 collisions?
It looks like you're starting with a zeroed seed, and then flipping 8 bits for each character at a time in each guess, since each character has 8 bits. Maybe instead of working at a character level, you could make guesses for each hash value, there are 8 of them in SHA256.
https://en.wikipedia.org/wiki/SHA-2#PseudocodeThe problem with what you're doing is that there are no math properties of characters in a SHA256 digest. There are mathematical properties in the 8 32-bit hash values because a bunch of discrete mathematics operations are done on them to get new hash values. And then they are concatenated together to give the SHA256 hash.
What I mean is that you could make an initial guess of the hash values like this:
(first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19):
h0 := 0x6a09e667
h1 := 0xbb67ae85
h2 := 0x3c6ef372
h3 := 0xa54ff53a
h4 := 0x510e527f
h5 := 0x9b05688c
h6 := 0x1f83d9ab
h7 := 0x5be0cd19
And then you can keep one of these hash values constant and repeatedly replace the others with different values using some kind of modulo function. As each of these values are 4 hex numbers long you can verify 4 hex characters at a time. But it makes more sense to verify them at the integer level by storing the target SHA256 hash as an 8 element array of 32-bit ints and comparing integers for equality directly.