3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* $string = 'This is my encrypted string!'; $key = 'KEY'; $split = str_split($string, 3); foreach($split as $chars) echo bin2hex($chars ^ $key); */ function hamdist($a, $b) { $a = str_split($a); $b = str_split($b); $len = count($a); $dist = 0; for($i = 0; $i < $len; $i++) { $bits['a'] = str_split(sprintf('%08d', decbin(ord($a[$i])))); $bits['b'] = str_split(sprintf('%08d', decbin(ord($b[$i])))); for($x = 0, $len2 = count($bits['a']); $x < $len2; $x++) if($bits['a'][$x] != $bits['b'][$x]) $dist++; } return $dist; } $enc = hex2bin('1f2d3038653038653432653c25262b32352d2e217938312b222b3e6a'); for($keysize = 2; $keysize <= 15; $keysize++) { $blockA = substr($enc, 0, $keysize); $blockB = substr($enc, $keysize, $keysize); printf("(Keysize = %d)\t%.2f\n", $keysize, (hamdist($blockA, $blockB) / $keysize)); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 6
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 6
Branch analysis from position: 31
Branch analysis from position: 6
filename:       /in/1RGrN
function name:  (null)
number of ops:  32
compiled vars:  !0 = $enc, !1 = $keysize, !2 = $blockA, !3 = $blockB
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   INIT_FCALL                                               'hex2bin'
          1        SEND_VAL                                                 '1f2d3038653038653432653c25262b32352d2e217938312b222b3e6a'
          2        DO_ICALL                                         $4      
          3        ASSIGN                                                   !0, $4
   36     4        ASSIGN                                                   !1, 2
          5      > JMP                                                      ->29
   38     6    >   INIT_FCALL                                               'substr'
          7        SEND_VAR                                                 !0
          8        SEND_VAL                                                 0
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $7      
         11        ASSIGN                                                   !2, $7
   39    12        INIT_FCALL                                               'substr'
         13        SEND_VAR                                                 !0
         14        SEND_VAR                                                 !1
         15        SEND_VAR                                                 !1
         16        DO_ICALL                                         $9      
         17        ASSIGN                                                   !3, $9
   41    18        INIT_FCALL                                               'printf'
         19        SEND_VAL                                                 '%28Keysize+%3D+%25d%29%09%25.2f%0A'
         20        SEND_VAR                                                 !1
         21        INIT_FCALL                                               'hamdist'
         22        SEND_VAR                                                 !2
         23        SEND_VAR                                                 !3
         24        DO_FCALL                                      0  $11     
         25        DIV                                              ~12     $11, !1
         26        SEND_VAL                                                 ~12
         27        DO_ICALL                                                 
   36    28        PRE_INC                                                  !1
         29    >   IS_SMALLER_OR_EQUAL                                      !1, 15
         30      > JMPNZ                                                    ~15, ->6
   42    31    > > RETURN                                                   1

Function hamdist:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 63
Branch analysis from position: 63
2 jumps found. (Code = 44) Position 1 = 65, Position 2 = 15
Branch analysis from position: 65
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 60
Branch analysis from position: 60
2 jumps found. (Code = 44) Position 1 = 62, Position 2 = 52
Branch analysis from position: 62
2 jumps found. (Code = 44) Position 1 = 65, Position 2 = 15
Branch analysis from position: 65
Branch analysis from position: 15
Branch analysis from position: 52
2 jumps found. (Code = 43) Position 1 = 58, Position 2 = 59
Branch analysis from position: 58
2 jumps found. (Code = 44) Position 1 = 62, Position 2 = 52
Branch analysis from position: 62
Branch analysis from position: 52
Branch analysis from position: 59
filename:       /in/1RGrN
function name:  hamdist
number of ops:  67
compiled vars:  !0 = $a, !1 = $b, !2 = $len, !3 = $dist, !4 = $i, !5 = $bits, !6 = $x, !7 = $len2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2        INIT_FCALL                                               'str_split'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $8      
          5        ASSIGN                                                   !0, $8
   16     6        INIT_FCALL                                               'str_split'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $10     
          9        ASSIGN                                                   !1, $10
   17    10        COUNT                                            ~12     !0
         11        ASSIGN                                                   !2, ~12
   18    12        ASSIGN                                                   !3, 0
   21    13        ASSIGN                                                   !4, 0
         14      > JMP                                                      ->63
   23    15    >   INIT_FCALL                                               'str_split'
         16        INIT_FCALL                                               'sprintf'
         17        SEND_VAL                                                 '%2508d'
         18        INIT_FCALL                                               'decbin'
         19        INIT_FCALL                                               'ord'
         20        FETCH_DIM_R                                      ~17     !0, !4
         21        SEND_VAL                                                 ~17
         22        DO_ICALL                                         $18     
         23        SEND_VAR                                                 $18
         24        DO_ICALL                                         $19     
         25        SEND_VAR                                                 $19
         26        DO_ICALL                                         $20     
         27        SEND_VAR                                                 $20
         28        DO_ICALL                                         $21     
         29        ASSIGN_DIM                                               !5, 'a'
         30        OP_DATA                                                  $21
   24    31        INIT_FCALL                                               'str_split'
         32        INIT_FCALL                                               'sprintf'
         33        SEND_VAL                                                 '%2508d'
         34        INIT_FCALL                                               'decbin'
         35        INIT_FCALL                                               'ord'
         36        FETCH_DIM_R                                      ~23     !1, !4
         37        SEND_VAL                                                 ~23
         38        DO_ICALL                                         $24     
         39        SEND_VAR                                                 $24
         40        DO_ICALL                                         $25     
         41        SEND_VAR                                                 $25
         42        DO_ICALL                                         $26     
         43        SEND_VAR                                                 $26
         44        DO_ICALL                                         $27     
         45        ASSIGN_DIM                                               !5, 'b'
         46        OP_DATA                                                  $27
   26    47        ASSIGN                                                   !6, 0
         48        FETCH_DIM_R                                      ~29     !5, 'a'
         49        COUNT                                            ~30     ~29
         50        ASSIGN                                                   !7, ~30
         51      > JMP                                                      ->60
   27    52    >   FETCH_DIM_R                                      ~32     !5, 'a'
         53        FETCH_DIM_R                                      ~33     ~32, !6
         54        FETCH_DIM_R                                      ~34     !5, 'b'
         55        FETCH_DIM_R                                      ~35     ~34, !6
         56        IS_NOT_EQUAL                                             ~33, ~35
         57      > JMPZ                                                     ~36, ->59
         58    >   PRE_INC                                                  !3
   26    59    >   PRE_INC                                                  !6
         60    >   IS_SMALLER                                               !6, !7
         61      > JMPNZ                                                    ~39, ->52
   21    62    >   PRE_INC                                                  !4
         63    >   IS_SMALLER                                               !4, !2
         64      > JMPNZ                                                    ~41, ->15
   30    65    > > RETURN                                                   !3
   31    66*     > RETURN                                                   null

End of function hamdist

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.18 ms | 1407 KiB | 28 Q