3v4l.org

run code in 300+ PHP versions simultaneously
<?php $my_secret = sodium_hex2bin("da93b1db433cfb2efe490a1bb263e440b586b6167c20b86f14cd058515806940"); $my_public = sodium_crypto_scalarmult_base($my_secret); $scott_secret = random_bytes(32); $scott_public = sodium_crypto_scalarmult_base($scott_secret); $my_shared_with_scott = sodium_crypto_scalarmult($my_secret, $scott_public); $scott_shared_with_me = sodium_crypto_scalarmult($scott_secret, $my_public); echo 'An attacker can only see: ', PHP_EOL; var_dump([ 'my public' => sodium_bin2hex($my_public), 'scott public' => sodium_bin2hex($scott_public) ]); echo 'Together, we calculated a shared secret for encryption: ', PHP_EOL; var_dump([ 'I see' => sodium_bin2hex($my_shared_with_scott), 'Scott sees' => sodium_bin2hex($scott_shared_with_me) ]);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DkmmI
function name:  (null)
number of ops:  53
compiled vars:  !0 = $my_secret, !1 = $my_public, !2 = $scott_secret, !3 = $scott_public, !4 = $my_shared_with_scott, !5 = $scott_shared_with_me
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL_BY_NAME                                       'sodium_hex2bin'
          1        SEND_VAL_EX                                              'da93b1db433cfb2efe490a1bb263e440b586b6167c20b86f14cd058515806940'
          2        DO_FCALL                                      0  $6      
          3        ASSIGN                                                   !0, $6
    4     4        INIT_FCALL_BY_NAME                                       'sodium_crypto_scalarmult_base'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $8      
          7        ASSIGN                                                   !1, $8
    6     8        INIT_FCALL                                               'random_bytes'
          9        SEND_VAL                                                 32
         10        DO_ICALL                                         $10     
         11        ASSIGN                                                   !2, $10
    7    12        INIT_FCALL_BY_NAME                                       'sodium_crypto_scalarmult_base'
         13        SEND_VAR_EX                                              !2
         14        DO_FCALL                                      0  $12     
         15        ASSIGN                                                   !3, $12
    9    16        INIT_FCALL_BY_NAME                                       'sodium_crypto_scalarmult'
         17        SEND_VAR_EX                                              !0
         18        SEND_VAR_EX                                              !3
         19        DO_FCALL                                      0  $14     
         20        ASSIGN                                                   !4, $14
   10    21        INIT_FCALL_BY_NAME                                       'sodium_crypto_scalarmult'
         22        SEND_VAR_EX                                              !2
         23        SEND_VAR_EX                                              !1
         24        DO_FCALL                                      0  $16     
         25        ASSIGN                                                   !5, $16
   12    26        ECHO                                                     'An+attacker+can+only+see%3A+'
         27        ECHO                                                     '%0A'
   13    28        INIT_FCALL                                               'var_dump'
   15    29        INIT_FCALL_BY_NAME                                       'sodium_bin2hex'
         30        SEND_VAR_EX                                              !1
         31        DO_FCALL                                      0  $18     
         32        INIT_ARRAY                                       ~19     $18, 'my+public'
   17    33        INIT_FCALL_BY_NAME                                       'sodium_bin2hex'
         34        SEND_VAR_EX                                              !3
         35        DO_FCALL                                      0  $20     
         36        ADD_ARRAY_ELEMENT                                ~19     $20, 'scott+public'
         37        SEND_VAL                                                 ~19
         38        DO_ICALL                                                 
   20    39        ECHO                                                     'Together%2C+we+calculated+a+shared+secret+for+encryption%3A+'
         40        ECHO                                                     '%0A'
   21    41        INIT_FCALL                                               'var_dump'
   23    42        INIT_FCALL_BY_NAME                                       'sodium_bin2hex'
         43        SEND_VAR_EX                                              !4
         44        DO_FCALL                                      0  $22     
         45        INIT_ARRAY                                       ~23     $22, 'I+see'
   25    46        INIT_FCALL_BY_NAME                                       'sodium_bin2hex'
         47        SEND_VAR_EX                                              !5
         48        DO_FCALL                                      0  $24     
         49        ADD_ARRAY_ELEMENT                                ~23     $24, 'Scott+sees'
         50        SEND_VAL                                                 ~23
         51        DO_ICALL                                                 
   26    52      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.8 ms | 1400 KiB | 17 Q