Skip to content

Commit 2321bfd

Browse files
authored
Update README.md
1 parent 6099885 commit 2321bfd

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ perl_set $secure_token '
7676
use POSIX qw(strftime);
7777
7878
my $now = time();
79+
my $key = "my_very_secret_key";
80+
my $expire = 60;
7981
my $tz = strftime("%z", localtime($now));
8082
$tz =~ s/(\d{2})(\d{2})/$1:$2/;
8183
my $timestamp = strftime("%Y-%m-%dT%H:%M:%S", localtime($now)) . $tz;
82-
my $expire = 60;
83-
my $key = "my_very_secret_key";
8484
my $r = shift;
8585
my $data = $r->uri;
8686
my $digest = hmac_sha256_base64($data . $timestamp . $expire, $key);
@@ -94,12 +94,11 @@ perl_set $secure_token '
9494
A similar function in PHP
9595

9696
```php
97-
$stringtosign = "/files/top_secret.pdf{$timestam}{$expire}";
9897
$secret = 'my_very_secret_key';
9998
$expire = 60;
10099
$algo = 'sha256';
101100
$timestamp = date('c');
102-
101+
$stringtosign = "/files/top_secret.pdf{$timestam}{$expire}";
103102
$hashmac = base64_encode(hash_hmac($algo, $stringtosign, $secret, true));
104103
$hashmac = strtr($hashmac, '+/', '-_'));
105104
$hashmac = str_replace('=', '', $hashmac);

0 commit comments

Comments
 (0)