<?php
$file_id = 1;
$project_id = 1;
$token = $project_id;
$expiry = strtotime('+1 years');
$signature = hash_hmac('sha256', "{$file_id}-{$token}-{$expiry}", "shared-secret");
$url = "https://media.example.com/?file_id={$file_id}&token={$token}&expiry={$expiry}&signature={$signature}";
var_dump($file_id, $token, $expiry, $signature, $url);
- Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.3, 7.2.5 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- int(1)
int(1)
int(1427202418)
string(64) "ad5de2f34db367962d1e9d327a30e571eb455faee5275eb97933bacf315c14c8"
string(137) "https://media.example.com/?file_id=1&token=1&expiry=1427202418&signature=ad5de2f34db367962d1e9d327a30e571eb455faee5275eb97933bacf315c14c8"
- Output for 7.2.4
- int(1)
int(1)
int(1427202419)
string(64) "fe3baefe26f7b09b94a892fed2443248301e52d28ebfb3e53097460d7ff75dd7"
string(137) "https://media.example.com/?file_id=1&token=1&expiry=1427202419&signature=fe3baefe26f7b09b94a892fed2443248301e52d28ebfb3e53097460d7ff75dd7"
- Output for 5.1.2 - 5.1.6, 5.2.0 - 5.2.17
- int(1)
int(1)
int(1427202417)
string(64) "e8af64053608be62e6936d6f380e33d32fb42913d80f3372b5314c52c205f06b"
string(137) "https://media.example.com/?file_id=1&token=1&expiry=1427202417&signature=e8af64053608be62e6936d6f380e33d32fb42913d80f3372b5314c52c205f06b"
- Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.1
- Fatal error: Call to undefined function hash_hmac() in /in/q8v3h on line 7
Process exited with code 255. - Output for 4.4.5 - 4.4.9
- Fatal error: Call to undefined function: hash_hmac() in /in/q8v3h on line 7
Process exited with code 255. - Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
- Fatal error: Call to undefined function: hash_hmac() in /in/q8v3h on line 7
Process exited with code 255. - Output for 4.3.0 - 4.3.1
- Fatal error: Call to undefined function: hash_hmac() in /in/q8v3h on line 7
preferences:
241.05 ms | 401 KiB | 460 Q