I think I can use Cantor's to create a unique hash n = ((x + y)*(x + y) + x - y)/2...
but can I reverse this hash? And if not, can someone provide a similar formula pair for a reversible hash?
Thanks.
if x and y and n are all the same data types.
n = ((x + y)*(x + y) + x - y)/2...
when x and y are near the datatype::max n will overflow and you will lose information and not be able to recover x and y.
If on the other hand if x and y are always within a range let say 0-FOO
n = Foo * x + y
can be a recoverable hash provided again n has not overflown
n % Foo
will give you y. Once y is known (n-y)/Foo will give you x
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With