PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php function base64url_encode($data) { return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); } function encode_token($key, $data) { $nonce = random_bytes(24); $stream_url = $data['hlsu']; unset($data['hlsu']); return base64url_encode( '1|' . $nonce . sodium_crypto_aead_xchacha20poly1305_ietf_encrypt( json_encode($data), '1|' . $stream_url, $nonce, base64_decode($key) ) ); } $stream_url = "https://box5.gideo.video/hls/123/directorscut.m3u8"; $token = encode_token( // Base64-encoded encryption key. 'HdEg0dJZXaamOlqQ7D8IgVbxt1d3OlVw8/BOwO/bUKM=', array( // Amember user ID. "sub" => 1234, // Current unix time. "iat" => time(), // User's current IP ($_GET['REMOTE_ADDR'] if no CDN or reverse proxy). "ip" => "255.255.255.255", // Stream URL. "hlsu" => $stream_url, // Platform (always use "web"; OTT will use a different value) "os" => "web", ) ); $stream_url .= '?t=' . $token;
Show:  
Copy Clear