3v4l.org

run code in 500+ PHP versions simultaneously
<?php //require('functions.inc.php'); $b64='./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; function encode64_one(int $src): string { global $b64; return $b64[$src&0x3f]; } function encode64_uint32(int $src, int $srcbits): string { global $b64; $dst=''; for($bit=0; $bit<$srcbits; $bit+=6) { $i=$src&0x3F; $c=encode64_one($i); $dst.=$c; $src>>=6; } return $dst; } function encode64(string $src): string { $srclen=strlen($src); $dst=''; for($i=0; $i<$srclen;) { //third param missing voluntarily $value=0; $bits=0; do { $value|=ord($src[$i++])<<$bits; $bits+=8; } while($bits<24 && $i<$srclen); $dnext=encode64_uint32($value, $bits); $dst.=$dnext; } return $dst; } function decode64_one(string $src): int { global $b64; $dst=strpos($b64, $src); return $dst; } function decode64_uint32(string $src): int { $dstbits=strlen($src)*6; $bit=0; $value=0; $dst=''; $i=0; for($bit=0; $bit<$dstbits; $bit+=6) { $one=decode64_one($src[$i]); $i++; $value|=$one<<$bit; } return $value; } function decode64(string $src): string { $srclen=strlen($src); $dst=''; for($i=0;$i<$srclen;$i+=4) { $n=decode64_uint32(substr($src,$i,4)); $s=pack('V', $n); $s=substr($s,0,3); $dst.=$s; } return $dst; } $password='password'; $hash=sodium_crypto_pwhash_scryptsalsa208sha256_str('password', SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_INTERACTIVE, SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_INTERACTIVE); var_dump($hash); $length=32; $ar=explode('$',$hash); $salt=substr($ar[2],11); var_dump($salt); $hash=$ar[3]; var_dump($hash); $salt=decode64($salt); if(strlen($salt)>SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_SALTBYTES) $salt=substr($salt,0,SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_SALTBYTES); $opslimit=524288; $memlimit=16777216; $hash2=sodium_crypto_pwhash_scryptsalsa208sha256($length,$password,$salt,$opslimit,$memlimit); $hash2=encode64($hash2); var_dump($hash2);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 42
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
filename:       /in/MTPvd
function name:  (null)
number of ops:  60
compiled vars:  !0 = $b64, !1 = $password, !2 = $hash, !3 = $length, !4 = $ar, !5 = $salt, !6 = $opslimit, !7 = $memlimit, !8 = $hash2
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                       !0, '.%2F0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
   65     1        ASSIGN                                                       !1, 'password'
   66     2        INIT_FCALL_BY_NAME                                           'sodium_crypto_pwhash_scryptsalsa208sha256_str'
          3        SEND_VAL_EX                                                  'password'
          4        FETCH_CONSTANT                                       ~11     'SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_INTERACTIVE'
          5        SEND_VAL_EX                                                  ~11
          6        FETCH_CONSTANT                                       ~12     'SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_INTERACTIVE'
          7        SEND_VAL_EX                                                  ~12
          8        DO_FCALL                                          0  $13     
          9        ASSIGN                                                       !2, $13
   67    10        INIT_FCALL                                                   'var_dump'
         11        SEND_VAR                                                     !2
         12        DO_ICALL                                                     
   68    13        ASSIGN                                                       !3, 32
   69    14        INIT_FCALL                                                   'explode'
         15        SEND_VAL                                                     '%24'
         16        SEND_VAR                                                     !2
         17        DO_ICALL                                             $17     
         18        ASSIGN                                                       !4, $17
   70    19        FETCH_DIM_R                                          ~19     !4, 2
         20        FRAMELESS_ICALL_2                substr              ~20     ~19, 11
         21        ASSIGN                                                       !5, ~20
   71    22        INIT_FCALL                                                   'var_dump'
         23        SEND_VAR                                                     !5
         24        DO_ICALL                                                     
   72    25        FETCH_DIM_R                                          ~23     !4, 3
         26        ASSIGN                                                       !2, ~23
   73    27        INIT_FCALL                                                   'var_dump'
         28        SEND_VAR                                                     !2
         29        DO_ICALL                                                     
   74    30        INIT_FCALL                                                   'decode64'
         31        SEND_VAR                                                     !5
         32        DO_FCALL                                          0  $26     
         33        ASSIGN                                                       !5, $26
   75    34        STRLEN                                               ~28     !5
         35        FETCH_CONSTANT                                       ~29     'SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_SALTBYTES'
         36        IS_SMALLER                                                   ~29, ~28
         37      > JMPZ                                                         ~30, ->42
         38    >   FETCH_CONSTANT                                       ~31     'SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_SALTBYTES'
         39        FRAMELESS_ICALL_3                substr              ~32     !5, 0
         40        OP_DATA                                                      ~31
         41        ASSIGN                                                       !5, ~32
   76    42    >   ASSIGN                                                       !6, 524288
   77    43        ASSIGN                                                       !7, 16777216
   78    44        INIT_FCALL_BY_NAME                                           'sodium_crypto_pwhash_scryptsalsa208sha256'
         45        SEND_VAR_EX                                                  !3
         46        SEND_VAR_EX                                                  !1
         47        SEND_VAR_EX                                                  !5
         48        SEND_VAR_EX                                                  !6
         49        SEND_VAR_EX                                                  !7
         50        DO_FCALL                                          0  $36     
         51        ASSIGN                                                       !8, $36
   79    52        INIT_FCALL                                                   'encode64'
         53        SEND_VAR                                                     !8
         54        DO_FCALL                                          0  $38     
         55        ASSIGN                                                       !8, $38
   80    56        INIT_FCALL                                                   'var_dump'
         57        SEND_VAR                                                     !8
         58        DO_ICALL                                                     
         59      > RETURN                                                       1

Function encode64_one:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MTPvd
function name:  encode64_one
number of ops:  8
compiled vars:  !0 = $src, !1 = $b64
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   RECV                                                 !0      
    6     1        BIND_GLOBAL                                                  !1, 'b64'
    7     2        BW_AND                                               ~2      !0, 63
          3        FETCH_DIM_R                                          ~3      !1, ~2
          4        VERIFY_RETURN_TYPE                                           ~3
          5      > RETURN                                                       ~3
    8     6*       VERIFY_RETURN_TYPE                                           
          7*     > RETURN                                                       null

End of function encode64_one

Function encode64_uint32:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 6
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 6
Branch analysis from position: 17
Branch analysis from position: 6
filename:       /in/MTPvd
function name:  encode64_uint32
number of ops:  21
compiled vars:  !0 = $src, !1 = $srcbits, !2 = $b64, !3 = $dst, !4 = $bit, !5 = $i, !6 = $c
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   10     2        BIND_GLOBAL                                                  !2, 'b64'
   11     3        ASSIGN                                                       !3, ''
   12     4        ASSIGN                                                       !4, 0
          5      > JMP                                                          ->15
   13     6    >   BW_AND                                               ~9      !0, 63
          7        ASSIGN                                                       !5, ~9
   14     8        INIT_FCALL                                                   'encode64_one'
          9        SEND_VAR                                                     !5
         10        DO_FCALL                                          0  $11     
         11        ASSIGN                                                       !6, $11
   15    12        ASSIGN_OP                                         8          !3, !6
   16    13        ASSIGN_OP                                         7          !0, 6
   12    14        ASSIGN_OP                                         1          !4, 6
         15    >   IS_SMALLER                                                   !4, !1
         16      > JMPNZ                                                        ~16, ->6
   18    17    >   VERIFY_RETURN_TYPE                                           !3
         18      > RETURN                                                       !3
   19    19*       VERIFY_RETURN_TYPE                                           
         20*     > RETURN                                                       null

End of function encode64_uint32

Function encode64:
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 = 29, Position 2 = 6
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 46) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 8
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 6
Branch analysis from position: 29
Branch analysis from position: 6
Branch analysis from position: 8
Branch analysis from position: 20
filename:       /in/MTPvd
function name:  encode64
number of ops:  33
compiled vars:  !0 = $src, !1 = $srclen, !2 = $dst, !3 = $i, !4 = $value, !5 = $bits, !6 = $dnext
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   20     0  E >   RECV                                                 !0      
   21     1        STRLEN                                               ~7      !0
          2        ASSIGN                                                       !1, ~7
   22     3        ASSIGN                                                       !2, ''
   23     4        ASSIGN                                                       !3, 0
          5      > JMP                                                          ->27
   24     6    >   ASSIGN                                                       !4, 0
   25     7        ASSIGN                                                       !5, 0
   27     8    >   INIT_FCALL                                                   'ord'
          9        POST_INC                                             ~13     !3
         10        FETCH_DIM_R                                          ~14     !0, ~13
         11        SEND_VAL                                                     ~14
         12        DO_ICALL                                             $15     
         13        SL                                                   ~16     $15, !5
         14        ASSIGN_OP                                         9          !4, ~16
   28    15        ASSIGN_OP                                         1          !5, 8
   29    16        IS_SMALLER                                           ~19     !5, 24
         17      > JMPZ_EX                                              ~19     ~19, ->20
         18    >   IS_SMALLER                                           ~20     !3, !1
         19        BOOL                                                 ~19     ~20
         20    > > JMPNZ                                                        ~19, ->8
   30    21    >   INIT_FCALL                                                   'encode64_uint32'
         22        SEND_VAR                                                     !4
         23        SEND_VAR                                                     !5
         24        DO_FCALL                                          0  $21     
         25        ASSIGN                                                       !6, $21
   31    26        ASSIGN_OP                                         8          !2, !6
   23    27    >   IS_SMALLER                                                   !3, !1
         28      > JMPNZ                                                        ~24, ->6
   33    29    >   VERIFY_RETURN_TYPE                                           !2
         30      > RETURN                                                       !2
   34    31*       VERIFY_RETURN_TYPE                                           
         32*     > RETURN                                                       null

End of function encode64

Function decode64_one:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MTPvd
function name:  decode64_one
number of ops:  8
compiled vars:  !0 = $src, !1 = $b64, !2 = $dst
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   35     0  E >   RECV                                                 !0      
   36     1        BIND_GLOBAL                                                  !1, 'b64'
   37     2        FRAMELESS_ICALL_2                strpos              ~3      !1, !0
          3        ASSIGN                                                       !2, ~3
   38     4        VERIFY_RETURN_TYPE                                           !2
          5      > RETURN                                                       !2
   39     6*       VERIFY_RETURN_TYPE                                           
          7*     > RETURN                                                       null

End of function decode64_one

Function decode64_uint32:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 10
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 10
Branch analysis from position: 21
Branch analysis from position: 10
filename:       /in/MTPvd
function name:  decode64_uint32
number of ops:  25
compiled vars:  !0 = $src, !1 = $dstbits, !2 = $bit, !3 = $value, !4 = $dst, !5 = $i, !6 = $one
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   40     0  E >   RECV                                                 !0      
   41     1        STRLEN                                               ~7      !0
          2        MUL                                                  ~8      ~7, 6
          3        ASSIGN                                                       !1, ~8
   42     4        ASSIGN                                                       !2, 0
   43     5        ASSIGN                                                       !3, 0
   44     6        ASSIGN                                                       !4, ''
   45     7        ASSIGN                                                       !5, 0
   46     8        ASSIGN                                                       !2, 0
          9      > JMP                                                          ->19
   47    10    >   INIT_FCALL                                                   'decode64_one'
         11        FETCH_DIM_R                                          ~15     !0, !5
         12        SEND_VAL                                                     ~15
         13        DO_FCALL                                          0  $16     
         14        ASSIGN                                                       !6, $16
   48    15        PRE_INC                                                      !5
   49    16        SL                                                   ~19     !6, !2
         17        ASSIGN_OP                                         9          !3, ~19
   46    18        ASSIGN_OP                                         1          !2, 6
         19    >   IS_SMALLER                                                   !2, !1
         20      > JMPNZ                                                        ~22, ->10
   51    21    >   VERIFY_RETURN_TYPE                                           !3
         22      > RETURN                                                       !3
   52    23*       VERIFY_RETURN_TYPE                                           
         24*     > RETURN                                                       null

End of function decode64_uint32

Function decode64:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 6
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 6
Branch analysis from position: 24
Branch analysis from position: 6
filename:       /in/MTPvd
function name:  decode64
number of ops:  28
compiled vars:  !0 = $src, !1 = $srclen, !2 = $dst, !3 = $i, !4 = $n, !5 = $s
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   53     0  E >   RECV                                                 !0      
   54     1        STRLEN                                               ~6      !0
          2        ASSIGN                                                       !1, ~6
   55     3        ASSIGN                                                       !2, ''
   56     4        ASSIGN                                                       !3, 0
          5      > JMP                                                          ->22
   57     6    >   INIT_FCALL                                                   'decode64_uint32'
          7        FRAMELESS_ICALL_3                substr              ~10     !0, !3
          8        OP_DATA                                                      4
          9        SEND_VAL                                                     ~10
         10        DO_FCALL                                          0  $11     
         11        ASSIGN                                                       !4, $11
   58    12        INIT_FCALL                                                   'pack'
         13        SEND_VAL                                                     'V'
         14        SEND_VAR                                                     !4
         15        DO_ICALL                                             $13     
         16        ASSIGN                                                       !5, $13
   59    17        FRAMELESS_ICALL_3                substr              ~15     !5, 0
         18        OP_DATA                                                      3
         19        ASSIGN                                                       !5, ~15
   60    20        ASSIGN_OP                                         8          !2, !5
   56    21        ASSIGN_OP                                         1          !3, 4
         22    >   IS_SMALLER                                                   !3, !1
         23      > JMPNZ                                                        ~19, ->6
   62    24    >   VERIFY_RETURN_TYPE                                           !2
         25      > RETURN                                                       !2
   63    26*       VERIFY_RETURN_TYPE                                           
         27*     > RETURN                                                       null

End of function decode64

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
133.81 ms | 505 KiB | 17 Q