လက်ရှိတည်နေရာ: ပင်မစာမျက်နှာ> ဖန်ရှင်အမျိုးအစားများ> crypt

crypt

တစ်လမ်းသွား string ကို hash
အမည်:crypt
အမျိုးအစား:ကြိုး
programming language:php
တစ်ကြောင်းဖြင့်အကျဉ်းချုပ်:တစ်လမ်းသွား string ကိုစာဝှက်စနစ်နည်းလမ်း (ဆေးထည့်) ။

အဓိပ္ပါယ်နှင့်အသုံးပြုမှု

crypt() function ကို des, blowfish, ဒါမှမဟုတ် md5 algorithm ကိုသုံးပြီး string ကိုပြန်ပို့သည်။

လုပ်ဆောင်ချက်သည်မတူညီသော operating systems များအပေါ်ကွဲပြားခြားနားစွာပြုမူပြီးအချို့သော operating systems များသည် algorithm type တစ်ခုထက် ပို. ထောက်ပံ့သည်။ installation စဉ်အတွင်း PHP သည် algorithms ရရှိနိုင်ကြောင်းစစ်ဆေးသည်နှင့် Algorithms ကိုအသုံးပြုသည်ကိုစစ်ဆေးသည်။

သတ်သတ်မှတ်မှတ် algorithm သည် ဆား parameter သည် format နှင့်အရှည်ပေါ်တွင်မူတည်သည်။ သတ်သတ်မှတ်မှတ် encryption method ကို သုံး. သတ်သတ်မှတ်မှတ် string တစ်ခုဖြင့်ထုတ်လုပ်သောကြိုးများတိုးပွားလာခြင်းအားဖြင့် ဆားသည် စာဝှက်စနစ်ကိုလုံခြုံစေနိုင်သည်။

ဤတွင် crypt() function ကိုအသုံးပြုသော Containtian အချို့ကိုဒီမှာရှိပါတယ်။ ဤစဉ်ဆက်မပြတ်တန်ဖိုးများကို installation အချိန်မှာ PHP ကသတ်မှတ်ထားသည်။

စဉ်ဆက်မပြတ်:

[crypt_salt_length] default encryption အရှည်။ အရှည် 2 နှင့်အတူစံ des encryption ကိုသုံးပါ
[crypt_std_des] Hash သည်စံ des algorithm ကို အခြေခံ. "./0-9a -za -z -z" ဇာတ်ကောင်ကိုဆားတန်ဖိုးအဖြစ်အသုံးပြုသည်။ ဆားတန်ဖိုးများတွင်တရားမ 0 င်စာလုံးများကိုအသုံးပြုခြင်းသည် crypt () ကျရှုံးခြင်းကိုဖြစ်စေလိမ့်မည်။
[crypt_ext_des] des algorithm အပေါ် အခြေခံ. တိုးချဲ့ hash တိုးချဲ့။ အက်ခရာ 9 လုံး၏ဆားတန်ဖိုးဖြင့် string တစ်ခုနှင့်အတူ 1 တွင်ဖော်ပြထားခြင်း 1 တွင် 4-byte သံသရာနှင့် 4-byte cycle နှင့် 4-byte ဆားတန်ဖိုးရှိသည်။ ၎င်းတို့သည် printable အက္ခရာများသို့ encoded နေကြသည်, ဇာတ်ကောင်တစ်ခုစီတွင် 6-bits ရှိသည်။ အနည်းဆုံးသိသိသာသာ bits ပိုမိုနှစ်သက်သည်။ 0 မှ 63 ကို "./0-9a -za-z" အဖြစ် encoded နေကြသည်။ ဆားတန်ဖိုးများတွင်တရားမ 0 င်စာလုံးများကိုအသုံးပြုခြင်းသည် crypt () ကျရှုံးခြင်းကိုဖြစ်စေလိမ့်မည်။
[crypt_md5] MD5 hash သည် 12 ဒေါ်လာဖြင့် စ. အက္ခရာစဉ် 1 ဒေါ်လာဖြင့်ဒေါ်လာ 1 ဒေါ်လာဖြင့်အသုံးပြုသည်။
[crypt_blowfish] Blowfish algorithm သည်အောက်ပါဆားတန်ဖိုးကိုအသုံးပြုသည် - Bit-Bit Cost parameter, "$" $ "နှင့် 64-bit string နှင့် 64-bit string နှင့် 64-bit string နှင့် 64-bit string နှင့် 64-bit string တို့ဖြင့်အသုံးပြုသည်။ ဤအကွာအဝေးပြင်ပရှိအက္ခရာများကိုအသုံးပြုခြင်းဆားတန်ဖိုးရှိစာလုံးများကိုအသုံးပြုခြင်းသည်အချည်းနှီးသော string ကိုပြန်ပို့ရန် () crypt () ကိုဖြစ်စေနိုင်သည်။ Two-Bit TwoP Parameter သည် Logarithm ဖြစ်ပြီး Base 2 တွင် loops အရေအတွက်နှင့်၎င်း၏အကွာအဝေးမှာ 04-31 ဖြစ်သည်။ ဒီအကွာအဝေးကျော်လွန်ပြီး crypt () ကျရှုံးဖို့ဖြစ်ပေါ်စေလိမ့်မယ်။
crypt_sha256 Sha-256 algorithm သည်ဒေါ်လာ 5 ဒေါ်လာဖြင့်စတင်သော 16 ဇာတ်ကောင် string ကိုဆားတန်ဖိုးကို သုံး. algorithm ကို hashed ။ အကယ်. ဆားတန်ဖိုး string ကို "Rounds = <n> $" ဖြင့်စတင်ပါက Numer of Numeric တန်ဖိုးကို Blowfish algorithm ၏ကုန်ကျစရိတ် parameter ကိုသတ်မှတ်သည်။ ပုံမှန် loops အရေအတွက်သည် 5000 ဖြစ်ပြီးအနည်းဆုံး 1000 ဖြစ်ပြီးအများဆုံးမှာ 9999999999 ဖြစ်သည်။ ဤအကွာအဝေးပြင်ပတွင်အနီးဆုံးတန်ဖိုးကိုပြောင်းလဲလိမ့်မည်။
crypt_sha512 Sha-512 algorithm သည် 4 င်း၏ဒေါ်လာ 6 ဒေါ်လာဖြင့်ဒေါ်လာ 6 ဒေါ်လာဖြင့်အသုံးပြုသည်။ အကယ်. ဆားတန်ဖိုး string ကို "Rounds = <n> $" ဖြင့်စတင်ပါက Numer of Numeric တန်ဖိုးကို Blowfish algorithm ၏ကုန်ကျစရိတ် parameter ကိုသတ်မှတ်သည်။ ပုံမှန် loops အရေအတွက်သည် 5000 ဖြစ်ပြီးအနည်းဆုံး 1000 ဖြစ်ပြီးအများဆုံးမှာ 9999999999 ဖြစ်သည်။ ဤအကွာအဝေးပြင်ပတွင်အနီးဆုံးတန်ဖိုးကိုပြောင်းလဲလိမ့်မည်။

ဤလုပ်ဆောင်မှုသည် algorithms များစွာကိုအထောက်အပံ့ပေးသောစနစ်များတွင်, အထက်ဖော်ပြပါစဉ်ဆက်မပြတ်ထောက်ခံပါက၎င်းကို "0" ဟုသတ်မှတ်ထားသည်။

မှတ်စု: သက်ဆိုင်ရာစာဝှက်ဖြည်သည့် function မရှိပါ။ crypt() function ကိုတစ်လမ်းတည်း algorithm ကိုအသုံးပြုသည်။

နမူနာ

ဤဥပမာတွင်ကျွန်ုပ်တို့သည်မတူညီသော algorithms များကိုစစ်ဆေးလိမ့်မည်။

 <? PHP
// နှစ်ခု - ဇာတ်ကောင်ဆား
အကယ်. ( crypt_std_des == 1 )
{
Echo "Standard Des:" ။ Crypt ( 'တစ်ခုခု' , 'st' ' ။ "\ n <br>" ;
}
သို့မဟုတ်
{
ECHO "စံသတ်မှတ်ချက်မထောက်ပံ့ရ။ \ n <br>" ;
}

// 4 ဇာတ်ကောင်ဆား
အကယ်. ( Crypt_ext_des == 1 )
{
ECHO "DEL:" ။ Crypt ( '`` ` ` _s4...... some ' ) ။ "\ n <br>" ;
}
သို့မဟုတ်
{
ECHO "ပံ့ပိုးမှုမရှိတဲ့ desped des ။ \ n <br>" ;
}

// 12 အက္ခရာများ $ 1 $ နှင့်အတူစတင်
အကယ်. ( Crypt_md5 == 1 )
{
ECHO "MD5:" ။ Crypt ( 'တစ်ခုခု' , '$ 1 $ somethin $' ) ။ "\ n <br>" ;
}
သို့မဟုတ်
{
ECHO "MD5 ကိုမထောက်ပံ့ပါ။ \ n <br>" ;
}

// $ 2A $ နှင့်အတူစတင်ဆား။ နှစ်ဆကိန်းဂဏန်းများအတွက်ကုန်ကျစရိတ် parameters တွေကို: 09 ။ 22 ဇာတ်ကောင်
အကယ်. ( Crypt_blowfish == 1 )
{
ပဲ့တင်သံ "blowfish:" ။ Crypt ( 'တစ်ခုခု' ' ' '' $ 2A $ 09 $ anexamplineforsalt $ ' ) ။ "\ n <br>" ;
}
သို့မဟုတ်
{
echo "blowfish des des မထောက်ပံ့ဘူး။ \ n <br>" ;
}

// 16- ဇာတ်ကောင်ဆား $ 5 $ နှင့်အတူစတင်။ အ 0 န်း၏ပုံသေနံပါတ်သည် 5000 ဖြစ်သည်။
if ( Crypt_sha256 == 1 )
{
ပဲ့တင်သံ "Sha-256:" ။ Crypt ( 'တစ်ခုခု' , '$ 5 $ + = 5000 $ AnexamplestringForsalt $' ) ။ "\ n <br>" ; }
သို့မဟုတ်
{
ECHO "Sha-256 ကိုမထောက်ပံ့ပါ။ \ n <br>" ;
}

// 16- ဇာတ်ကောင်ဆား $ 5 $ နှင့်အတူစတင်။ အ 0 န်း၏ပုံသေနံပါတ်သည် 5000 ဖြစ်သည်။
အကယ်. ( Crypt_sha512 == 1 )
{
Echo "Sha-512:" ။ Crypt ( 'တစ်ခုခု' , '$ 6 ဒေါ်လာ = 5000 $ anexamplestringforsalt $' ' ;
}
သို့မဟုတ်
{
ECHO "Sha-512 ကိုမထောက်ပံ့ပါ။ " ;
}
>

အထက်ပါကုဒ်များ၏ output ကို (operating system ပေါ် မူတည်. ):

 စံ des: stqadd7zlbbyi
Extended des: _s4....someqxidlbptuuu6
MD5: $ 1 $ somethin $ 4nzkruy6r7k7.rdeoz0w ။
Blowfish: $ 2A $ 09 $ 09 $ anexamplingforsaleloukejrjrjrjrlexmf1671Qw3khl49r3dfu3
Sha-256: $ 5 ဒေါ်လာ $ anexamplestringf $ kirctqsxo2wg50 / hs4jti4pmonkqupmonkqugwfxlvy9vu9
Sha-512: $ 6 $ 6000 = 5000 $ anexamplestringf $ oo0skoadudopxkqxjpwzo05wgrhg0dhuapbaou /
onbgpceklf / 7ovm5wnes0w2vwuga0o24olzgqp1xki6lq0 ။

သဒ္ဒါ

 Crypt ( Str , Sal )
တေးရေး ဖေါ်ပြ
str လိုအပ်ပါတယ် encoded ခံရဖို့ string ကိုဖေါ်ပြသည်။
ဆား optional ကို။ encoding encoding ကိုပိုမိုလုံခြုံစေရန် encoded ဇာတ်ကောင်အရေအတွက်တိုးပွားစေရန်အသုံးပြုခဲ့သည်။ အကယ်. ဆား parameter သည်မထောက်ပံ့ပါက PHP သည် function ကိုခေါ်သည့်အခါတိုင်းတစ် ဦး ချင်းစီကိုထုတ်ပေးလိမ့်မည်။
ဆက်စပ်အကြောင်းအရာ
သက်ဆိုင်သောဖင်ခှ်ရှင်းများ
  • နံပါတ်များမှ single-byte ကြိုးများကိုထုတ်လုပ်ပါ chr

    chr

    နံပါတ်များမှsingle-b
  • strings များကို array သို့ပြောင်းပါ str_split

    str_split

    stringsများကိုarrayသ
  • backslash ကိုအသုံးပြုပြီးကြိုးမှထွက်ပြေး addslashes

    addslashes

    backslashကိုအသုံးပြု
  • Rtrim ၏ alias chop

    chop

    Rtrim၏alias
  • Locale Settings အပေါ်အခြေခံပြီးကြိုးများနှိုင်းယှဉ် strcoll

    strcoll

    LocaleSettingsအပေါ်အ
  • စာလုံးများကိုဘာသာပြန်ပါသို့မဟုတ်အစားထိုး substrings ကိုအစားထိုးပါ - သတ်မှတ်ထားသောစာလုံးများကိုပြောင်းပါ strtr

    strtr

    စာလုံးများကိုဘာသာပြန
  • ငွေကြေး strings သို့နံပါတ်များကို format လုပ်ပါ money_format

    money_format

    ငွေကြေးstringsသို့နံ
  • addcslashes သုံး. string ကိုဆန့်ကျင်ရေးဆန့်ကျင်ရေးဆန့်ကျင်ရေး stripcslashes

    stripcslashes

    addcslashesသုံး.stri