Created
March 23, 2018 19:55
-
-
Save lfbittencourt/f1a528519a0b12004541fa2328326ab5 to your computer and use it in GitHub Desktop.
Simple reversible hashing class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class SimpleCrypt | |
{ | |
protected static $factor = 2 / 3 / 5 / 7 / 11 / 13 / 17 / 19 / 23 / 29; | |
public static function crypt($value) | |
{ | |
$hash = ceil($value / self::$factor); | |
return $hash; | |
} | |
public static function decrypt($hash) | |
{ | |
$value = floor($hash * self::$factor); | |
return (int) $value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment