Heim >Backend-Entwicklung >PHP-Tutorial >rest-Azure REST API中的Authorization中的头标到底该怎么写——CSDN问答频道

rest-Azure REST API中的Authorization中的头标到底该怎么写——CSDN问答频道

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-02 11:00:591103Durchsuche

restphpazure

Authorization中的头标到底该怎么写
官方给出的格式如下

<code>Authorization="[SharedKey|SharedKeyLite] <accountname>:<signature>" </signature></accountname></code>

主要是部分,官方给出的生成方法如下

<code>Signature=Base64(HMAC-SHA256(UTF8(StringToSign)))</code>

如此,在php中,生成HMAC-SHA256的函数是(参考了PHP: hash_hmac -Manual)

<code>hash_hmac ( string $algo , string $data , string $key [, bool $raw_output = false ] )</code>

我是这么使用的

<code>hash_hmac('sha256',$str,'');</code>

那么问题来了,这种函数需要的第三个参数是一个key,不然无法生成结果。这里的key到底要填啥??

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn