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 ($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/kQtYI
function name:  (null)
number of ops:  8
compiled vars:  !0 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   ASSIGN                                                   !0, 'secret'
   43     1        INIT_FCALL                                               'strtonum'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 5381
          4        SEND_VAL                                                 33
          5        DO_FCALL                                      0  $2      
          6        ECHO                                                     $2
   66     7      > RETURN                                                   1

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

End of function string_inthash

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.35 ms | 1398 KiB | 29 Q