0
$\begingroup$

If you created two very large numbers represented by binary data (perhaps using sha512 with random input for each hash) could you determine what binary block is numerically larger by iterating over bytes from left (largest bit) to right (smallest bit)? If at any point the left has a 0 bit where the right has a 1, you’d know the right is larger. Where the bytes are the same, you eliminate them and continue iterating to the right.

Would this work?

$\endgroup$

2 Answers 2

1
$\begingroup$

Yes, this is exactly how a comparison is done. It works for unsigned integers of a fixed length. It is also called lexicographic order.

$\endgroup$
1
  • $\begingroup$ Thanks for the info!! $\endgroup$
    – MichaelICE
    Dec 20, 2021 at 16:19
0
$\begingroup$

I think this would work, I just found memcmp in c++, and I think that is how memcnp works

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.