3v4l.org

run code in 200+ php & hhvm versions
<?php generate(); // FUNCTION function generate() { $digilist = "0123456789ABCDEFGHJKLMNPQRTUVWXY"; //now we generate a new random ID number using the substrings of the digitList string above for( $i = 0; $i < 100; $i++) { $three_chars = NULL; $three_chars .= substr( $digilist, rand( 1, 9 ), 1 ); $three_chars .= substr( $digilist, rand( 10, 31 ), 1 ); $three_chars .= substr( $digilist, rand( 10, 31 ), 1 ); if ($i < 10) { $three_chars .= '0'; $three_chars .= $i; } else { $three_chars .= $i; } $id = $three_chars; $key = get_key( $id ); echo $id . ":" . $key . "\n"; } } function get_key( $id ) { $digilist = "0123456789ABCDEFGHJKLMNPQRTUVWXY"; //ok so now we need to generate an MD5 hash of our ID $hash = md5($id); //cycle through the hash 16 (length of key) times (in steps of 2 because each hex bytes is 2 digits long) $i = 0; $key = NULL; for ($i; $i < 32; $i+=2) { //here we convert the next hex value to an integer and perform a bitwise AND operation against '31' //31 is the highest substring value in our digit list. $nextdigit = hexdec(substr($hash, $i, 2)) & 31; //if 'i' is divisable by 8 (every 4 cycles) then we want to add "-" if ((($i % 8) == 0) && ($i > 0)) { $key .= "-".substr($digilist, $nextdigit, 1); } else { $key .= substr($digilist, $nextdigit, 1); } } return $key; }
based on lLGja

Abusive script

This script was stopped while abusing our resources

Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rC5Dh
function name:  (null)
number of ops:  5
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   2     0  E >   INIT_FCALL_BY_NAME                                       'generate'
         1        DO_FCALL                                      0          
   6     2        NOP                                                      
  33     3        NOP                                                      
  59     4      > RETURN                                                   1

Function generate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
2 jumps found. (Code = 44) Position 1 = 53, Position 2 = 3
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 39
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 53, Position 2 = 3
Branch analysis from position: 53
Branch analysis from position: 3
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 53, Position 2 = 3
Branch analysis from position: 53
Branch analysis from position: 3
filename:       /in/rC5Dh
function name:  generate
number of ops:  54
compiled vars:  !0 = $digilist, !1 = $i, !2 = $three_chars, !3 = $id, !4 = $key
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   8     0  E >   ASSIGN                                                   !0, '0123456789ABCDEFGHJKLMNPQRTUVWXY'
  12     1        ASSIGN                                                   !1, 0
         2      > JMP                                                      ->51
  14     3    >   ASSIGN                                                   !2, null
  15     4        INIT_FCALL                                               'substr'
         5        SEND_VAR                                                 !0
         6        INIT_FCALL                                               'rand'
         7        SEND_VAL                                                 1
         8        SEND_VAL                                                 9
         9        DO_ICALL                                         $8      
        10        SEND_VAR                                                 $8
        11        SEND_VAL                                                 1
        12        DO_ICALL                                         $9      
        13        ASSIGN_CONCAT                                 0          !2, $9
  16    14        INIT_FCALL                                               'substr'
        15        SEND_VAR                                                 !0
        16        INIT_FCALL                                               'rand'
        17        SEND_VAL                                                 10
        18        SEND_VAL                                                 31
        19        DO_ICALL                                         $11     
        20        SEND_VAR                                                 $11
        21        SEND_VAL                                                 1
        22        DO_ICALL                                         $12     
        23        ASSIGN_CONCAT                                 0          !2, $12
  17    24        INIT_FCALL                                               'substr'
        25        SEND_VAR                                                 !0
        26        INIT_FCALL                                               'rand'
        27        SEND_VAL                                                 10
        28        SEND_VAL                                                 31
        29        DO_ICALL                                         $14     
        30        SEND_VAR                                                 $14
        31        SEND_VAL                                                 1
        32        DO_ICALL                                         $15     
        33        ASSIGN_CONCAT                                 0          !2, $15
  18    34        IS_SMALLER                                       ~17     !1, 10
        35      > JMPZ                                                     ~17, ->39
  20    36    >   ASSIGN_CONCAT                                 0          !2, '0'
  21    37        ASSIGN_CONCAT                                 0          !2, !1
        38      > JMP                                                      ->40
  25    39    >   ASSIGN_CONCAT                                 0          !2, !1
  27    40    >   ASSIGN                                                   !3, !2
  28    41        INIT_FCALL_BY_NAME                                       'get_key'
        42        SEND_VAR_EX                                              !3
        43        DO_FCALL                                      0  $22     
        44        ASSIGN                                                   !4, $22
  29    45        CONCAT                                           ~24     !3, '%3A'
        46        CONCAT                                           ~25     ~24, !4
        47        CONCAT                                           ~26     ~25, '%0A'
        48        ECHO                                                     ~26
  12    49        POST_INC                                         ~27     !1
        50        FREE                                                     ~27
        51    >   IS_SMALLER                                       ~28     !1, 100
        52      > JMPNZ                                                    ~28, ->3
  31    53    > > RETURN                                                   null

End of function generate

Function get_key:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 9
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 46) Position 1 = 22, Position 2 = 24
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 33
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 9
Branch analysis from position: 42
Branch analysis from position: 9
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 9
Branch analysis from position: 42
Branch analysis from position: 9
Branch analysis from position: 24
filename:       /in/rC5Dh
function name:  get_key
number of ops:  44
compiled vars:  !0 = $id, !1 = $digilist, !2 = $hash, !3 = $i, !4 = $key, !5 = $nextdigit
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  33     0  E >   RECV                                             !0      
  35     1        ASSIGN                                                   !1, '0123456789ABCDEFGHJKLMNPQRTUVWXY'
  37     2        INIT_FCALL                                               'md5'
         3        SEND_VAR                                                 !0
         4        DO_ICALL                                         $7      
         5        ASSIGN                                                   !2, $7
  40     6        ASSIGN                                                   !3, 0
  41     7        ASSIGN                                                   !4, null
  42     8      > JMP                                                      ->40
  46     9    >   INIT_FCALL                                               'hexdec'
        10        INIT_FCALL                                               'substr'
        11        SEND_VAR                                                 !2
        12        SEND_VAR                                                 !3
        13        SEND_VAL                                                 2
        14        DO_ICALL                                         $11     
        15        SEND_VAR                                                 $11
        16        DO_ICALL                                         $12     
        17        BW_AND                                           ~13     $12, 31
        18        ASSIGN                                                   !5, ~13
  49    19        MOD                                              ~15     !3, 8
        20        IS_EQUAL                                         ~16     ~15, 0
        21      > JMPZ_EX                                          ~16     ~16, ->24
        22    >   IS_SMALLER                                       ~17     0, !3
        23        BOOL                                             ~16     ~17
        24    > > JMPZ                                                     ~16, ->33
  51    25    >   INIT_FCALL                                               'substr'
        26        SEND_VAR                                                 !1
        27        SEND_VAR                                                 !5
        28        SEND_VAL                                                 1
        29        DO_ICALL                                         $18     
        30        CONCAT                                           ~19     '-', $18
        31        ASSIGN_CONCAT                                 0          !4, ~19
        32      > JMP                                                      ->39
  55    33    >   INIT_FCALL                                               'substr'
        34        SEND_VAR                                                 !1
        35        SEND_VAR                                                 !5
        36        SEND_VAL                                                 1
        37        DO_ICALL                                         $21     
        38        ASSIGN_CONCAT                                 0          !4, $21
  42    39    >   ASSIGN_ADD                                    0          !3, 2
        40    >   IS_SMALLER                                       ~24     !3, 32
        41      > JMPNZ                                                    ~24, ->9
  58    42    > > RETURN                                                   !4
  59    43*     > RETURN                                                   null

End of function get_key

Generated using Vulcan Logic Dumper, using php 7.3.0