Skip to content

Commit 5f3e6af

Browse files
authored
fixed readme typo + improvement (#17)
1 parent b922038 commit 5f3e6af

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,13 @@ $secret = 'my_very_secret_key';
102102
$expire = 60;
103103
$algo = 'sha256';
104104
$timestamp = date('c');
105-
$stringtosign = "/files/top_secret.pdf|{$timestamp}|{$expire}";
105+
$unixtimestamp = time();
106+
$stringtosign = "/files/top_secret.pdf|{$unixtimestamp}|{$expire}";
106107
$hashmac = base64_encode(hash_hmac($algo, $stringtosign, $secret, true));
107108
$hashmac = strtr($hashmac, '+/', '-_');
108109
$hashmac = str_replace('=', '', $hashmac);
109110
$host = $_SERVER['HTTP_HOST'];
110-
$loc = "https://{$host}/files/top_secret.pdf?st={$hashmac}&ts={$timestamp}&e={$expire}";
111+
$loc = "https://{$host}/files/top_secret.pdf?st={$hashmac}&ts={$unixtimestamp}&e={$expire}";
111112
```
112113

113114
Using Unix timestamp in Node.js

0 commit comments

Comments
 (0)