Aşağıdaki C# kodunu PHP'ye dönüştürmek istiyorum.Bu C# kodlama kodunun PHP karşılığı nedir?
C#: Ben bu dönüştü ettik
byte[] operation = UTF8Encoding.UTF8.GetBytes("getfaqs");
byte[] secret = UTF8Encoding.UTF8.GetBytes("Password");
var hmac = newHMACSHA256(secret);
byte[] hash = hmac.ComputeHash(operation);
:
Sonra$hash = hash_hmac("sha256", utf8_encode("getfaqs"), utf8_encode("Password"));
Ben: Bence
var apiKey = "ABC-DEF1234";
var authInfo = apiKey + ":" + hash
//base64 encode the authorisation info
var authorisationHeader = Convert.ToBase64String(Encoding.UTF8.GetBytes(authInfo));
olmalıdır:
$authInfo = base64_encode($apiKey . ":" . $hash);
Ya
$authInfo = base64_encode(utf8_encode($apiKey . ":" . $hash));
Ama belli değil
, bu ikinci kodlamayı fark Encoding.UTF8 değil UTF8Encoding.UTF8 kullanır.PHP kodu neye benzemeli?
'UTF8Encoding.UTF8' ve' Encoding.UTF8 'eşdeğerdir. 'UTF8Encoding'' Encoding''den miras aldığından, sonuç olarak 'UTF8' özelliği elde edilir. Yazım hatası düzeltildi - için –