PHP တွင် hash_update_stream () function သည်ကျွန်ုပ်တို့အား hash အခြေအနေကိုဖန်တီးထားသည့် hash အခြေအနေကိုမွမ်းမံရန်ခွင့်ပြုသည်။ တည်ငြိမ်သောအချက်အလက်များနှင့်မတူသည်မှာ streaming data များသည်အလွန်ကြီးမားနိုင်သည်သို့မဟုတ်မှတ်ဉာဏ်ထဲသို့မထည့်နိုင်ပါ, ထို့ကြောင့် streaming ကိုအသုံးပြုခြင်းသည်အလွန်အရေးကြီးသည်။ ဤဆောင်းပါးသည် zip: // (သို့) PHP: // PHP: // PHP: // filter) နှင့် တွဲဖက်. Hash_update_stram () function ကိုမည်သို့အသုံးပြုရမည်ကိုမိတ်ဆက်ပေးလိမ့်မည်။
hash_update_stream () သည် PHP တွင် hash function တစ်ခုဖြစ်သည်။ ၎င်း၏အသုံးပြုမှုအောက်ပါအတိုင်းဖြစ်သည် -
hash_update_stream ( resource $context , resource $handle [, int $length = 1024 ] ) : bool
$ Context : ဤသည် Hash_init () မှဖန်တီးထားသော hash အခြေအနေကိုဖြစ်ပါတယ်။
$ လက်ကိုင် - ဤသည်မှာဖိုင်လက်ကိုင်သို့မဟုတ်အခြား stream အမျိုးအစားကဲ့သို့သောစမ်းချောင်းမှဖတ်ရန်လိုအပ်သည့် data stream အရင်းအမြစ်ဖြစ်သည်။
$ အရှည် - ဤသည်မှာအချိန်ကိုဖတ်ရှုသည့် Bytes အရေအတွက်ကိုဆိုလိုသည်။ 1024 bytes သို့ default ဖြစ်သည်။
PHP တွင် ZIP: // သည် zip ဖိုင်များမှဒေတာစီးဆင်းမှုများကိုတိုက်ရိုက်ဖတ်ရန်အတွက်အထူး protocol တစ်ခုဖြစ်သည်။ သင် compressed file တစ်ခုရှိရန်လိုအပ်သည့်အခါ zip: // protocol မှတဆင့်ဖိုင်အကြောင်းအရာကိုသင်ကြည့်ရှုနိုင်ပြီး streaming data ကို process လုပ်ထားရန် hash_update_stream () ကို သုံးနိုင်သည်။
ကျွန်ုပ်တို့တွင် zip file lege.Zip zzip ရှိသည်ဆိုပါစို့။ ၎င်းသည် File.txt ဟုခေါ်သောစာသားဖိုင်ပါရှိသည်ဆိုပါစို့။ အောက်ပါကုဒ်ကိုသုံးနိုင်သည်။
<?php
// တစ် ဦး hash အခြေအနေဖန်တီးပါ
$hashContext = hash_init('sha256');
// အသုံးပြု zip:// protocol ကိုဖတ်ပါ ZIP ဖိုင်တစ်ခုအတွက်ဒေတာစီးဆင်းမှု
$zipStream = fopen('zip://example.zip#file.txt', 'r');
if ($zipStream) {
// Hash တန်ဖိုးကို Update လုပ်ပါ
while (!feof($zipStream)) {
hash_update_stream($hashContext, $zipStream);
}
fclose($zipStream);
// နောက်ဆုံး hash တန်ဖိုးကိုရယူပါ
$hashValue = hash_final($hashContext);
echo "SHA-256 Hash of the file: " . $hashValue;
} else {
echo "ဖိုင်ကိုဖွင့ ်. မရပါ!";
}
?>
PHP: // filter သည် သင့်အား input streams များကိုစစ်ထုတ်ရန်ခွင့်ပြုသည့်အလွန်အစွမ်းထက်သောစမ်းချောင်းထူမှုများဖြစ်သည်။ ဥပမာအားဖြင့် PHP: // filter မှတဆင့်အချက်အလက်များကိုချုံ့ခြင်း, decompress သို့မဟုတ်ပြောင်းလဲနိုင်သည်။ hash_update_stream () နှင့်ပေါင်းစပ်ပြီး, အချို့သော filter အချို့အားဖြင့်လုပ်ငန်းများ၌ပြုလုပ်ထားသောအချက်အလက်များကိုသင်ပြုလုပ်နိုင်သည်။
PHP: // filter မှတဆင့်စာသားဖိုင်၏ hash တန်ဖိုးကိုဖတ်ပြီးတွက်ချက်လိုသည်ဆိုပါစို့။ PHP: // filter ကို မည်သို့အသုံးပြုရမည်ကိုပြသသည့်ဥပမာတစ်ခုမှာ convert.Inonv.utf-8 / ISO-8859-1 ကိုဖတ်ရှုရန်နှင့် 4 င်း၏ hash ကိုတွက်ချက်ရန် PHP: // filter ကိုအသုံးပြုသည်။
<?php
// တစ် ဦး hash အခြေအနေဖန်တီးပါ
$hashContext = hash_init('md5');
// အသုံးပြု php://filter ဇာတ်ကောင် encoding ကိုဖတ်နှင့်ပြောင်းလဲ
$filteredStream = fopen('php://filter/read=convert.iconv.UTF-8/ISO-8859-1/resource=example.txt', 'r');
if ($filteredStream) {
// Hash တန်ဖိုးကို Update လုပ်ပါ
while (!feof($filteredStream)) {
hash_update_stream($hashContext, $filteredStream);
}
fclose($filteredStream);
// နောက်ဆုံး hash တန်ဖိုးကိုရယူပါ
$hashValue = hash_final($hashContext);
echo "MD5 Hash of the file after conversion: " . $hashValue;
} else {
echo "ဖိုင်ကိုဖွင့ ်. မရပါ!";
}
?>
Hash_update_stream () function ကို zip: // သို့မဟုတ် PHP: // filter protocol ကိုပေါင်းစပ်ခြင်းအားဖြင့်ကျွန်ုပ်တို့သည် compressed filter သို့မဟုတ် streaming data များပြုလုပ်နိုင်သည်။ streaming streaming processing supply special လုပ်နိုင်မှုစွမ်းရည်သည် data volume အလွန်ကြီးမားနေလျှင်ပင်မှတ်ဥာဏ်အလွန်အကျွံသုံးစွဲခြင်းမရှိဘဲပိုမိုထိရောက်သောတွက်ချက်မှုများကိုပိုမိုထိရောက်စွာတွက်ချက်သည် ။ zip ဖိုင်တစ်ခုမှဒေတာများကိုဖတ်ရှုခြင်းသို့မဟုတ်ဇာတ်ကောင် encoding encoding encoding encoding encoding encoding ပြောင်းလဲခြင်း, hash_update_stream () သည်ဤအခြေအနေများကိုကိုင်တွယ်ရန်ရိုးရှင်းသောနှင့်ထိရောက်သောနည်းလမ်းဖြစ်သည်။