3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * La fonction sodium_crypto_box_keypair() génère aléatoirement une clé secrète * et une clé publique correspondante. */ $aliceKeypair = sodium_crypto_box_keypair(); $alicePublicKey = sodium_crypto_box_publickey($aliceKeypair); $aliceSecretKey = sodium_crypto_box_secretkey($aliceKeypair); $bobKeypair = sodium_crypto_box_keypair(); $bobPublicKey = sodium_crypto_box_publickey($bobKeypair); $bobSecretKey = sodium_crypto_box_secretkey($bobKeypair); /** * Le nombre arbitraire n'a pas besoin d'être confidentiel, mais il doit être * utilisé avec une seule invocation de crypto_box_open() pour une paire * particulière de clés publiques et secrètes. */ $nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES); $aliceToBobKeyPair = sodium_crypto_box_keypair_from_secretkey_and_publickey($aliceSecretKey, $bobPublicKey); $message = 'Signed using Alice\'s secret key and to be encrypted using Bob\'s public key.'; $ciphertext = sodium_crypto_box($message, $nonce, $aliceToBobKeyPair); $bobToAliceKp = sodium_crypto_box_keypair_from_secretkey_and_publickey($bobSecretKey, $alicePublicKey); $plaintext = sodium_crypto_box_open($ciphertext, $nonce, $bobToAliceKp); echo $plaintext;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UtnS7
function name:  (null)
number of ops:  52
compiled vars:  !0 = $aliceKeypair, !1 = $alicePublicKey, !2 = $aliceSecretKey, !3 = $bobKeypair, !4 = $bobPublicKey, !5 = $bobSecretKey, !6 = $nonce, !7 = $aliceToBobKeyPair, !8 = $message, !9 = $ciphertext, !10 = $bobToAliceKp, !11 = $plaintext
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   INIT_FCALL_BY_NAME                                       'sodium_crypto_box_keypair'
          1        DO_FCALL                                      0  $12     
          2        ASSIGN                                                   !0, $12
    8     3        INIT_FCALL_BY_NAME                                       'sodium_crypto_box_publickey'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0  $14     
          6        ASSIGN                                                   !1, $14
    9     7        INIT_FCALL_BY_NAME                                       'sodium_crypto_box_secretkey'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0  $16     
         10        ASSIGN                                                   !2, $16
   11    11        INIT_FCALL_BY_NAME                                       'sodium_crypto_box_keypair'
         12        DO_FCALL                                      0  $18     
         13        ASSIGN                                                   !3, $18
   12    14        INIT_FCALL_BY_NAME                                       'sodium_crypto_box_publickey'
         15        SEND_VAR_EX                                              !3
         16        DO_FCALL                                      0  $20     
         17        ASSIGN                                                   !4, $20
   13    18        INIT_FCALL_BY_NAME                                       'sodium_crypto_box_secretkey'
         19        SEND_VAR_EX                                              !3
         20        DO_FCALL                                      0  $22     
         21        ASSIGN                                                   !5, $22
   20    22        INIT_FCALL                                               'random_bytes'
         23        FETCH_CONSTANT                                   ~24     'SODIUM_CRYPTO_SECRETBOX_NONCEBYTES'
         24        SEND_VAL                                                 ~24
         25        DO_ICALL                                         $25     
         26        ASSIGN                                                   !6, $25
   22    27        INIT_FCALL_BY_NAME                                       'sodium_crypto_box_keypair_from_secretkey_and_publickey'
         28        SEND_VAR_EX                                              !2
         29        SEND_VAR_EX                                              !4
         30        DO_FCALL                                      0  $27     
         31        ASSIGN                                                   !7, $27
   24    32        ASSIGN                                                   !8, 'Signed+using+Alice%27s+secret+key+and+to+be+encrypted+using+Bob%27s+public+key.'
   26    33        INIT_FCALL_BY_NAME                                       'sodium_crypto_box'
         34        SEND_VAR_EX                                              !8
         35        SEND_VAR_EX                                              !6
         36        SEND_VAR_EX                                              !7
         37        DO_FCALL                                      0  $30     
         38        ASSIGN                                                   !9, $30
   28    39        INIT_FCALL_BY_NAME                                       'sodium_crypto_box_keypair_from_secretkey_and_publickey'
         40        SEND_VAR_EX                                              !5
         41        SEND_VAR_EX                                              !1
         42        DO_FCALL                                      0  $32     
         43        ASSIGN                                                   !10, $32
   30    44        INIT_FCALL_BY_NAME                                       'sodium_crypto_box_open'
         45        SEND_VAR_EX                                              !9
         46        SEND_VAR_EX                                              !6
         47        SEND_VAR_EX                                              !10
         48        DO_FCALL                                      0  $34     
         49        ASSIGN                                                   !11, $34
   32    50        ECHO                                                     !11
         51      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
123.35 ms | 1448 KiB | 14 Q