Hash functions can be used for (not uniquely) identifying certain values. They are not guaranteed to be unique (better said, it is guaranteed that some different values will have identical hash codes). A small deviation in the value usualy results in a completely different hash code (As @Bobson already has mentioned.) Another use of hash codes is to find in-equality of two values in constant time.
It might be possible to design a hash code function that will do what you want, specialy if you know the domain your values are living in. But that will need a mathematical background to do.
As far as I know there is no hash function for the example you gave.
Here is another idea for integers, use modulo 10 operations and calculate the absolute difference betweeen each digit. This way you calculate the 'distance' between two number, not the 'difference'. I did something similar once on strings to find strings close to each other.
Some pseudo code:
int Distance(int x, int y)
{
int result = 0;
while ((x > 0) && (y > 0))
{
result += abs(x%10 - y%10);
x /= 10;
y /= 10;
}
return result;
}
void Caller()
{
int distance = Distance(123, 456);
if (distance == 0) write("x and y are equal");
else write("the relative distance between x and y = " + distance.ToString())'
}