File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff 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 '
9494A 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);
You can’t perform that action at this time.
0 commit comments