PHP Tripcode Function PHP 458
By IST on 2nd December 2019 10:05:27 PM

  1. function make_tripcode($pass) {
  2.   if ($pass === NULL || $pass === "") {
  3.     return "";
  4.   }
  5.   $pass = htmlspecialchars($pass); // don't replace apostrophes
  6.   $num_chars = iconv_strlen($pass, "UTF-8");
  7.   $conv = "";
  8.   for ($i = 0; $i < $num_chars; $i++) {
  9.     try {
  10.       $conv .= iconv("UTF-8", "CP932", iconv_substr($pass, $i, 1, "UTF-8"));
  11.     } catch (Exception $ex) {
  12.       $conv .= "?";
  13.     }
  14.   }
  15.   $salt1 = substr($conv . "H.", 1, 2);
  16.   $salt2 = preg_replace("/[^\.-z]/", ".", $salt1);
  17.   $salt = strtr($salt2, ":;<=>?@[\\]^_`", "ABCDEFGabcdef");
  18.   $trip1 = crypt($conv, $salt);
  19.   $trip = substr($trip1, -10);
  20.   return "!" . $trip;
  21. }
  22.  
  23.  
  24. $pass = 'USERNAME#PASSWORD';
  25. echo make_tripcode($pass) . "\n";
Raw Paste

Login or Register to edit or fork this paste. It's free.