Supported Versions: PHP 5 >= 5.1.2, PHP 7, PHP 8, PECL hash >= 1.1
Generate a keyed hash value using the HMAC method
<?php hash_hmac( string $algo, string $data, string $key, bool $binary = false): string
<?php $canonical_request = "GET\n" . $encoded_uri . "\n" . $query_string . "\n" . $header_string . "\n" . $signed_headers_string . "\nUNSIGNED-PAYLOAD";
$string_to_sign = $algorithm . "\n" . $time_text . "\n" . $scope . "\n" . hash('sha256', $canonical_request,
false);
$signing_key = hash_hmac('sha256', 'aws4_request',
hash_hmac('sha256', 's3',
hash_hmac('sha256', $AWSRegion,
hash_hmac('sha256', $date_text, 'AWS4' . $AWSSecretAccessKey, true),
true),
true),
true
);
$signature = hash_hmac('sha256', $string_to_sign, $signing_key);
return 'https://' . $hostname . $encoded_uri . '?' . $query_string . '&X-Amz-Signature=' . $signature;
<?php $string_to_sign = $algorithm . "\n" . $time_text . "\n" . $scope . "\n" . hash('sha256', $canonical_request,
false);
$signing_key = hash_hmac('sha256', 'aws4_request',
hash_hmac('sha256', 's3',
hash_hmac('sha256', $AWSRegion,
hash_hmac('sha256', $date_text, 'AWS4' . $AWSSecretAccessKey, true),
true),
true),
true
);
$signature = hash_hmac('sha256', $string_to_sign, $signing_key);
<?php false);
$signing_key = hash_hmac('sha256', 'aws4_request',
hash_hmac('sha256', 's3',
hash_hmac('sha256', $AWSRegion,
hash_hmac('sha256', $date_text, 'AWS4' . $AWSSecretAccessKey, true),
true),
true),
true
);
<?php $signing_key = hash_hmac('sha256', 'aws4_request',
hash_hmac('sha256', 's3',
hash_hmac('sha256', $AWSRegion,
hash_hmac('sha256', $date_text, 'AWS4' . $AWSSecretAccessKey, true),
true),
true),
true
<?php true),
true
);
$signature = hash_hmac('sha256', $string_to_sign, $signing_key);
return 'https://' . $hostname . $encoded_uri . '?' . $query_string . '&X-Amz-Signature=' . $signature;
}
<?php $canonical_request = "GET\n" . $encoded_uri . "\n" . $query_string . "\n" . $header_string . "\n" . $signed_headers_string . "\nUNSIGNED-PAYLOAD";
$string_to_sign = $algorithm . "\n" . $time_text . "\n" . $scope . "\n" . hash('sha256', $canonical_request,
false);
$signing_key = hash_hmac('sha256', 'aws4_request',
hash_hmac('sha256', 's3',
hash_hmac('sha256', $AWSRegion,
hash_hmac('sha256', $date_text, 'AWS4' . $AWSSecretAccessKey, true),
true),
true),
true
);
$signature = hash_hmac('sha256', $string_to_sign, $signing_key);
return 'https://' . $hostname . $encoded_uri . '?' . $query_string . '&X-Amz-Signature=' . $signature;
<?php $string_to_sign = $algorithm . "\n" . $time_text . "\n" . $scope . "\n" . hash('sha256', $canonical_request,
false);
$signing_key = hash_hmac('sha256', 'aws4_request',
hash_hmac('sha256', 's3',
hash_hmac('sha256', $AWSRegion,
hash_hmac('sha256', $date_text, 'AWS4' . $AWSSecretAccessKey, true),
true),
true),
true
);
$signature = hash_hmac('sha256', $string_to_sign, $signing_key);
<?php false);
$signing_key = hash_hmac('sha256', 'aws4_request',
hash_hmac('sha256', 's3',
hash_hmac('sha256', $AWSRegion,
hash_hmac('sha256', $date_text, 'AWS4' . $AWSSecretAccessKey, true),
true),
true),
true
);
<?php $signing_key = hash_hmac('sha256', 'aws4_request',
hash_hmac('sha256', 's3',
hash_hmac('sha256', $AWSRegion,
hash_hmac('sha256', $date_text, 'AWS4' . $AWSSecretAccessKey, true),
true),
true),
true
<?php true),
true
);
$signature = hash_hmac('sha256', $string_to_sign, $signing_key);
return 'https://' . $hostname . $encoded_uri . '?' . $query_string . '&X-Amz-Signature=' . $signature;
}
<?php $canonical_request = "GET\n" . $encoded_uri . "\n" . $query_string . "\n" . $header_string . "\n" . $signed_headers_string . "\nUNSIGNED-PAYLOAD";
$string_to_sign = $algorithm . "\n" . $time_text . "\n" . $scope . "\n" . hash('sha256', $canonical_request,
false);
$signing_key = hash_hmac('sha256', 'aws4_request',
hash_hmac('sha256', 's3',
hash_hmac('sha256', $AWSRegion,
hash_hmac('sha256', $date_text, 'AWS4' . $AWSSecretAccessKey, true),
true),
true),
true
);
$signature = hash_hmac('sha256', $string_to_sign, $signing_key);
return 'https://' . $hostname . $encoded_uri . '?' . $query_string . '&X-Amz-Signature=' . $signature;
<?php $string_to_sign = $algorithm . "\n" . $time_text . "\n" . $scope . "\n" . hash('sha256', $canonical_request,
false);
$signing_key = hash_hmac('sha256', 'aws4_request',
hash_hmac('sha256', 's3',
hash_hmac('sha256', $AWSRegion,
hash_hmac('sha256', $date_text, 'AWS4' . $AWSSecretAccessKey, true),
true),
true),
true
);
$signature = hash_hmac('sha256', $string_to_sign, $signing_key);
<?php false);
$signing_key = hash_hmac('sha256', 'aws4_request',
hash_hmac('sha256', 's3',
hash_hmac('sha256', $AWSRegion,
hash_hmac('sha256', $date_text, 'AWS4' . $AWSSecretAccessKey, true),
true),
true),
true
);
<?php $signing_key = hash_hmac('sha256', 'aws4_request',
hash_hmac('sha256', 's3',
hash_hmac('sha256', $AWSRegion,
hash_hmac('sha256', $date_text, 'AWS4' . $AWSSecretAccessKey, true),
true),
true),
true
<?php true),
true
);
$signature = hash_hmac('sha256', $string_to_sign, $signing_key);
return 'https://' . $hostname . $encoded_uri . '?' . $query_string . '&X-Amz-Signature=' . $signature;
}