bytes(SODIUM_CRYPTO_SECRETBOX_KEYBYTES); $encryptor = new StateEncryptor($encryptionKey, $crypto, $random); $encrypted = $encryptor->encrypt('test'); $decoded = base64_decode($encrypted, strict: true); echo "Total encrypted data length: " . strlen($decoded) . " bytes\n"; echo "Version byte (position 0): " . ord($decoded[0]) . "\n"; // Extract nonce (after version byte, should be 24 bytes) $nonce = substr($decoded, 1, 24); echo "Extracted nonce length: " . strlen($nonce) . " bytes\n"; echo "Nonce hex: " . bin2hex($nonce) . "\n"; // Check what's at positions 0-25 echo "\nByte-by-byte breakdown:\n"; echo "Position 0 (version): " . ord($decoded[0]) . "\n"; for ($i = 1; $i <= 24; $i++) { echo "Position {$i}: " . (isset($decoded[$i]) ? sprintf("%02x", ord($decoded[$i])) : 'N/A') . "\n"; }