Skip to content

Instantly share code, notes, and snippets.

@lfbittencourt
Created March 23, 2018 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lfbittencourt/f1a528519a0b12004541fa2328326ab5 to your computer and use it in GitHub Desktop.
Save lfbittencourt/f1a528519a0b12004541fa2328326ab5 to your computer and use it in GitHub Desktop.
Simple reversible hashing class
<?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