You seem to be a little confused:
Quote:
If you replace the public key with any string which is small enough it will work correctly.
SHA is a hashing algorithm, not an encryption algorithm - it doesn't use a key, public or private.
Hashing algorithms always generate a value with the same size - that's the whole point - and they do that by "throwing away" information, and as such are not "reversible": you cannot guarantee to get the original input back from the output value. Encryption algorithms are different - they use a key to make the output data much, much harder to reverse back to get the original input.
If you code is any good for generating SHA values, then it should work for any size input. So at a guess, you are assuming something wrongly, or trying to do something that isn't actually possible.