I have a string s
like:
username-password-{random}
I would like to generate the hash SHA256 of the string s
, such that first 2 bytes of the hash equal to 0, like:
0000afcbd546843....
So, username-password-
is fixed and we can random the {random}
part, is there any way to control the random
part to get the SHA256 satisfy that condition.
I have the code bash script below, but I have run many time, it does not meet the condition.
pt="0000"
counter=10000000
while [ $counter -le 20000000 ]
do
echo $counter
fibyte=$(echo -n ""username-password-"$counter" | sha256sum | cut -c1-4)
if [ "$fibyte" == "$pt" ]
then
echo ""username-password-"$counter"
echo =======================================================
break
fi
((counter++))
done
echo DONE
Aucun commentaire:
Enregistrer un commentaire