File tree 1 file changed +3
-4
lines changed
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 '
76
76
use POSIX qw(strftime);
77
77
78
78
my $now = time();
79
+ my $key = "my_very_secret_key";
80
+ my $expire = 60;
79
81
my $tz = strftime("%z", localtime($now));
80
82
$tz =~ s/(\d{2})(\d{2})/$1:$2/;
81
83
my $timestamp = strftime("%Y-%m-%dT%H:%M:%S", localtime($now)) . $tz;
82
- my $expire = 60;
83
- my $key = "my_very_secret_key";
84
84
my $r = shift;
85
85
my $data = $r->uri;
86
86
my $digest = hmac_sha256_base64($data . $timestamp . $expire, $key);
@@ -94,12 +94,11 @@ perl_set $secure_token '
94
94
A similar function in PHP
95
95
96
96
``` php
97
- $stringtosign = "/files/top_secret.pdf{$timestam}{$expire}";
98
97
$secret = 'my_very_secret_key';
99
98
$expire = 60;
100
99
$algo = 'sha256';
101
100
$timestamp = date('c');
102
-
101
+ $stringtosign = "/files/top_secret.pdf{$timestam}{$expire}";
103
102
$hashmac = base64_encode(hash_hmac($algo, $stringtosign, $secret, true));
104
103
$hashmac = strtr($hashmac, '+/', '-_'));
105
104
$hashmac = str_replace('=', '', $hashmac);
You can’t perform that action at this time.
0 commit comments