Search code examples
phpmathhashbcmathcryptanalysis

Trying to decrypt a PHP PseudoCrypt class


I am trying to create a way to reverse the PseudoCrypt script listed at: http://blog.kevburnsjr.com/php-unique-hash. In this code it has the following equation:

$dec = ($num * $prime)-floor($num * $prime/$ceil)*$ceil;

I have been able to get every variable except for the $num. For instance take the following numbers:

$dec = 566201239;
$prime = 566201239;
$ceil = 916132832;

The equation would then look like this:

566201239 = ($num * 566201239)-floor($num * 566201239/916132832)*916132832;

The answer should be 1. However I have not determined the way make the equation = $num. I am wanting to use the hash it creates in a URL, then decrypt the hash to perform queries in my database.

Edit: If there is a better way to create a hash that will be unique with very little room for duplication I would be open to that instead.

Edit: Somehow I put the wrong value in for $dec. Edit: Blog posting updated with functioning code.


Solution

  • Thanks to some help from commenter Padraig Kennedy, the library has been upgraded to support reversibility
    http://blog.kevburnsjr.com/php-unique-hash