3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Unicode/multibyte capable equivelant of ord(). function charCodeAt($a, $b) { $a = mb_convert_encoding($a,"UCS-4BE","UTF-8"); $c = unpack("N", mb_substr($a,$b,1,"UCS-4BE")); return $c[1]; } // strToNum - Convert a string into a 32-bit integer. function strToNum ($str, $c, $k) { $Int32U = 4294967296; // 2^32 for ($i = 0; $i < mb_strlen($str); $i++) { $c *= $k; if (PHP_INT_MAX != 0x0000000080000000) { // 2147483647 $c = -(~($c & 0x00000000FFFFFFFF) + 1); } if ($c >= $Int32U) { $c = $c - ($Int32U * (int) ($c / $Int32U)); // if $c is less than -2^31 $c = ($c < 0x0000000080000000) ? ($c + $Int32U) : $c; } $c += charCodeAt($str, $i); } return $c; } function string_inthash($str) { $a = (int)preg_replace('#[^0-9]#u', '', sha1($str)) * (int)date('YmdHis'); if (PHP_INT_MAX != 0x0000000080000000) { // 2147483647 $a = -(~($a & 0x00000000FFFFFFFF) + 1); } return (int)$a; } $str = 'secret'; echo strToNum($str, 0x1505, 0x21); /* $a = date('YmdHi'); $b = 'secret'; $bb = sha1($b); $bc = preg_replace('#[^0-9]#u', '', $bb); $bd = (int)$bc - (int)$a; $c = "{$b}|{$a}"; $d = base64_encode($c); $e = base64_decode($d); echo $a . PHP_EOL; echo $b . PHP_EOL; echo $bb . PHP_EOL; echo $bc . PHP_EOL; echo $bd . PHP_EOL; echo $c . PHP_EOL; echo $d . PHP_EOL; echo $e . PHP_EOL; */
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C9nFn
function name:  (null)
number of ops:  8
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   ASSIGN                                                   !0, 'secret'
   45     1        INIT_FCALL                                               'strtonum'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 5381
          4        SEND_VAL                                                 33
          5        DO_FCALL                                      0  $2      
          6        ECHO                                                     $2
   68     7      > RETURN                                                   1

Function charcodeat:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C9nFn
function name:  charCodeAt
number of ops:  22
compiled vars:  !0 = $a, !1 = $b, !2 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_FCALL                                               'mb_convert_encoding'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'UCS-4BE'
          5        SEND_VAL                                                 'UTF-8'
          6        DO_ICALL                                         $3      
          7        ASSIGN                                                   !0, $3
    5     8        INIT_FCALL                                               'unpack'
          9        SEND_VAL                                                 'N'
         10        INIT_FCALL                                               'mb_substr'
         11        SEND_VAR                                                 !0
         12        SEND_VAR                                                 !1
         13        SEND_VAL                                                 1
         14        SEND_VAL                                                 'UCS-4BE'
         15        DO_ICALL                                         $5      
         16        SEND_VAR                                                 $5
         17        DO_ICALL                                         $6      
         18        ASSIGN                                                   !2, $6
    6    19        FETCH_DIM_R                                      ~8      !2, 1
         20      > RETURN                                                   ~8
    7    21*     > RETURN                                                   null

End of function charcodeat

Function strtonum:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 6
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 13
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 27
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 25
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 6
Branch analysis from position: 38
Branch analysis from position: 6
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 6
Branch analysis from position: 38
Branch analysis from position: 6
Branch analysis from position: 27
Branch analysis from position: 13
filename:       /in/C9nFn
function name:  strToNum
number of ops:  40
compiled vars:  !0 = $str, !1 = $c, !2 = $k, !3 = $Int32U, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   12     3        ASSIGN                                                   !3, 4294967296
   14     4        ASSIGN                                                   !4, 0
          5      > JMP                                                      ->33
   15     6    >   ASSIGN_OP                                     3          !1, !2
   17     7      > JMPZ                                                     <true>, ->13
   18     8    >   BW_AND                                           ~8      !1, 4294967295
          9        BW_NOT                                           ~9      ~8
         10        ADD                                              ~10     ~9, 1
         11        MUL                                              ~11     ~10, -1
         12        ASSIGN                                                   !1, ~11
   21    13    >   IS_SMALLER_OR_EQUAL                                      !3, !1
         14      > JMPZ                                                     ~13, ->27
   22    15    >   DIV                                              ~14     !1, !3
         16        CAST                                          4  ~15     ~14
         17        MUL                                              ~16     !3, ~15
         18        SUB                                              ~17     !1, ~16
         19        ASSIGN                                                   !1, ~17
   25    20        IS_SMALLER                                               !1, 2147483648
         21      > JMPZ                                                     ~19, ->25
         22    >   ADD                                              ~20     !1, !3
         23        QM_ASSIGN                                        ~21     ~20
         24      > JMP                                                      ->26
         25    >   QM_ASSIGN                                        ~21     !1
         26    >   ASSIGN                                                   !1, ~21
   28    27    >   INIT_FCALL                                               'charcodeat'
         28        SEND_VAR                                                 !0
         29        SEND_VAR                                                 !4
         30        DO_FCALL                                      0  $23     
         31        ASSIGN_OP                                     1          !1, $23
   14    32        PRE_INC                                                  !4
         33    >   INIT_FCALL                                               'mb_strlen'
         34        SEND_VAR                                                 !0
         35        DO_ICALL                                         $26     
         36        IS_SMALLER                                               !4, $26
         37      > JMPNZ                                                    ~27, ->6
   31    38    > > RETURN                                                   !1
   32    39*     > RETURN                                                   null

End of function strtonum

Function string_inthash:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 22
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/C9nFn
function name:  string_inthash
number of ops:  25
compiled vars:  !0 = $str, !1 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
   36     1        INIT_FCALL                                               'preg_replace'
          2        SEND_VAL                                                 '%23%5B%5E0-9%5D%23u'
          3        SEND_VAL                                                 ''
          4        INIT_FCALL                                               'sha1'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $2      
          7        SEND_VAR                                                 $2
          8        DO_ICALL                                         $3      
          9        CAST                                          4  ~4      $3
         10        INIT_FCALL                                               'date'
         11        SEND_VAL                                                 'YmdHis'
         12        DO_ICALL                                         $5      
         13        CAST                                          4  ~6      $5
         14        MUL                                              ~7      ~4, ~6
         15        ASSIGN                                                   !1, ~7
   37    16      > JMPZ                                                     <true>, ->22
   38    17    >   BW_AND                                           ~9      !1, 4294967295
         18        BW_NOT                                           ~10     ~9
         19        ADD                                              ~11     ~10, 1
         20        MUL                                              ~12     ~11, -1
         21        ASSIGN                                                   !1, ~12
   40    22    >   CAST                                          4  ~14     !1
         23      > RETURN                                                   ~14
   42    24*     > RETURN                                                   null

End of function string_inthash

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.65 ms | 1407 KiB | 29 Q