SHARE
TWEET

Hashes MySQL

porketero May 22nd, 2015 229 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $x = mysqli_connect('127.0.0.1', 'root', 'contraseña', 'db');
  2. $c = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ªº\\|!@"#~$%&/()=\'?';
  3. $k = strlen($c);
  4. function c($n)
  5. {
  6.         global $k, $c;
  7.         $s = '';
  8.         $r = 1;
  9.         $b = $n;
  10.         while($b > pow($k, $r))
  11.                 $b -= pow($k, $r++);
  12.         for($i = 0; $r > $i; $i++)
  13.                 $s = substr($c, ($n/pow($k,$i)-1)%$k, 1) . $s;
  14.         return $s;
  15. }
  16. $q = mysqli_query($x, 'SELECT id FROM hashes ORDER BY id DESC LIMIT 1');
  17. if(mysqli_num_rows($q) == 0)
  18.         $i = 0;
  19. else
  20. {
  21.         $p = mysqli_fetch_assoc($q);
  22.         $i = $p['id'];
  23. }
  24. echo number_format($i, 0, '.', '.');
  25. while(true)
  26. {
  27.         $i++;
  28.         $m = c($i);
  29.         $alg = hash_algos();
  30.         $sb = '';
  31.         $sa = '';
  32.         foreach(hash_algos() as $b => $al)
  33.         {
  34.                 $sb .= ', `' . $al . '`';
  35.                 $sa .= '\'' . hash($al, $m) . ((count(hash_algos()) > ($b + 1)) ? '\',' : '\'');
  36.         }
  37.         mysqli_query($x, 'INSERT INTO hashes (`value`' . $sb . ') VALUES (\'' . mysqli_real_escape_string($x, $m) . '\', ' . $sa . ')');
  38.         if($i%100 == 0)
  39.                 echo "\n" . number_format($i, 0, '.', '.');
RAW Paste Data
Want to get better at PHP?
Learn to code PHP in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top