php加密一个非常大的数字来产生一个较小的数字

I am dealing with very large numbers. One of my algorithms requires a number 'x' to be smaller than another number 'n', in order to perform that algorithm. I was wondering is it possible to encrypt the very large number to produce a smaller number and store the key for when I need to decrpyt the number back to a larger number? I have looked at mcrypt but that doesnt output all numbers, from what I have seen it outputs a string.

What you're talking about is called "compression", not "encryption".

If anything, encryption is likely to yield a larger string than its input. While you may be able to compress the number, it will be very slight savings.

Depending on the range of possible values, you may be able to simply build an array of every possible large number and work with array indexes instead of the numbers themselves.

You can convert the number to a higher base to represent it with less characters. For example, if your number is in base 10, convert it to base 16. You can use the GMP library to do math with great precision on these numbers not in base 10.

You can read about the GMP (Gnu Multiple Precision) library here: http://www.php.net/manual/en/book.gmp.php