Tarisa Pasiwedhi Simba neJavaScript uye Zvakajairika Mataurirwo

Tarisa Pasiwedhi Simba neJavaScript uye Zvakajairika Mataurirwo

Ini ndanga ndichiita imwe tsvagiridzo yekutsvaga yakanaka muenzaniso wePassword Simba rekutarisa iro rinoshandisa JavaScript uye Kugara Kutaura (Regex). Mukushandisa pabasa rangu, tinoita posvo kumashure kuti tione simba repassword uye hazvinetse kune vashandisi vedu.

Chii chinonzi Regex?

Chirevo chenguva dzose kuteedzana kwemavara anotsanangura maitiro ekutsvaga Kazhinji, mapatani akadaro anoshandiswa netambo kutsvaga algorithms e wana or tsvaga uye kutsiva mashandiro patambo, kana kusimbiswa kwekuisa. 

Ichi chinyorwa hachisi chokwadi chekukudzidzisa iwe kugara uchitaura. Ingo ziva kuti iko kugona kushandisa Zvakajairika Mataurirwo kuchanyatso kurerutsa kusimudzira kwako apo iwe uchitsvaga mapatani mune zvinyorwa. Izvo zvakare zvakakosha kuti uzive kuti mizhinji mitauro yekuvandudza yakagadzirisa kushandiswa kwekutaura kwese ... saka pane kupatsanura uye kutsvaga tambo nhanho-nhanho, Regex inowanzo kukurumidza zvakanyanya ese server uye mutengi-parutivi.

Ndakatsvaga padandemutande zvishoma ndisati ndawana muenzaniso ezvimwe zvikuru Zvigaro Zvenguva dzose zvinotarisa musanganiswa wehurefu, mavara, uye zviratidzo. Zvisinei, kodhi yacho yaive yakati wandei pane kuravira kwangu uye yakagadzirirwa NET. Saka ini ndakarerutsa kodhi ndokuiisa muJavaScript. Izvi zvinoita kuti isimbise simba repassword munguva chaiyo-nguva mubhurawuza remutengi usati waridzorera kumashure… uye rinopa imwe mhinduro kumushandisi pasimba repassword.

Nyora A Password

Nesimba rega rega rekhibhodi, password inoedzwa ichipesana neyakajairwa kutaura uyezve mhinduro inopihwa mushandisi muchikamu pasi payo.




Nyora pasiwedhi

Heino Code

The Kugara Kutaura ita basa rakanakisa rekudzora kureba kwekodhi:

  • Mamwe mavara - Kana kureba kuri pasi pevatambi vasere.
  • Kuneta - Kana kureba kwacho kuri pasi pevanhu gumi uye isina mubatanidzwa wezviratidzo, makepisi, zvinyorwa.
  • nzira - Kana kureba iine mavara gumi kana kupfuura uye iine mubatanidzwa wezviratidzo, makapisi, zvinyorwa.
  • simba - Kana iyo yakareba iine mavara gumi nemana kana kupfuura uye iine mubatanidzwa wezviratidzo, makapisi, zvinyorwa.

<script language="javascript">
    function passwordChanged() {
        var strength = document.getElementById('strength');
        var strongRegex = new RegExp("^(?=.{14,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
        var mediumRegex = new RegExp("^(?=.{10,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
        var enoughRegex = new RegExp("(?=.{8,}).*", "g");
        var pwd = document.getElementById("password");
        if (pwd.value.length == 0) {
            strength.innerHTML = 'Type Password';
        } else if (false == enoughRegex.test(pwd.value)) {
            strength.innerHTML = 'More Characters';
        } else if (strongRegex.test(pwd.value)) {
            strength.innerHTML = '<span style="color:green">Strong!</span>';
        } else if (mediumRegex.test(pwd.value)) {
            strength.innerHTML = '<span style="color:orange">Medium!</span>';
        } else {
            strength.innerHTML = '<span style="color:red">Weak!</span>';
        }
    }
</script>
<input name="password" id="password" type="text" size="15" maxlength="100" onkeyup="return passwordChanged();" />
<span id="strength">Type Password</span>

Kuomesa Chinyorwa Chako Chemashoko

Izvo zvakakosha kuti iwe usango simbisa iyo kuvaka password mukati meJavascript yako. Izvi zvinogonesa chero munhu ane mabhurawuza ekuvandudza maturusi ekupfuura script uye kushandisa chero password yavanoda. Iwe UNOGARA UCHISHANDISA server-padivi cheki kuti usimbise simba repaswedi usati warichengeta muchikuva chako.

32 Comments

  1. 1
  2. 2

    WAITA HAKO! WAITA HAKO! WAITA HAKO! Ndanga ndichinyengedza kutenderera kwemasvondo e2 neyakaipirwa password kodhi kodhi kubva kune mamwe mawebhusaiti uye ndichidhonza bvudzi rangu kunze. Yako ipfupi, inoshanda senge ini zvandinoda uye zvakanakisa pane zvese, zviri nyore kune yejavascript novice yekugadzirisa! Ini ndaida kutora simba mutongo uye kwete kurega iyo fomu post kuti inyatso gadziridza password yemushandisi kunze kwekunge yasangana neyesimba bvunzo. Imwe kodhi yevanhu yaive yakanyanya kuomarara kana yaisashanda nemazvo kana chimwewo chinhu. Ndinokuda! XXXXX

  3. 4

    tenda mwari nevanhu vanogona kunyatso kunyora chidimbu chekodhi zvakanaka.
    Aive neruzivo rwakafanana naJanis.

    Izvi zvinoshanda kunze kwebhokisi iro rakanakira vanhu vakaita seni vasingakwanise kodhi JavaScript!

  4. 5
  5. 6

    Mhoroi, chekutanga pane zvese ndatenda zvakanyanya nekuedza kwako, ndakaedza kushandisa izvi neAsp.net asi hazvina kushanda, ndiri kushandisa

    panzvimbo peteki, uye haina kushanda, chero mazano ?!

  6. 7

    Kuna Nisreen: kodhi iri mubhokisi rakakwenenzverwa haishande nekacheka'n'paste. Iyo imwechete quote yakanganiswa. Kodhi yekubatanidza yekuratidzira yakanaka asi.

  7. 8
  8. 9
  9. 10
  10. 11

    "P @ s $ w0rD" inoratidza yakasimba, kunyange yaizotsemurwa nekukurumidza nekurwiswa kweduramazwi.
    Kuendesa chimiro chakadai pamhinduro yehunyanzvi, ini ndinotenda zvakakosha kuti ubatanidze iyi algorithm ne dictionnary cheki.

  11. 12
  12. 13

    Kutenda nekodhi iyi diki ndinogona ikozvino kuishandisa kuyedza simba rangu repassword kana vashanyi vangu vachipinda mapassword avo,

  13. 14
  14. 15
  15. 16
  16. 17
  17. 18
  18. 19

    mumwe munhu anogona kutaura, nei isina kushanda yangu ..

    ndakateedzera kodhi yese, ndokuinama kunepad ++, asi haishande zvachose?
    ndokumbirawo undibatsire ..

  19. 20
  20. 21
  21. 22
  22. 23
  23. 24

    Rudzi urwu rwe "simba rekutarisa" rinotungamira vanhu munzira ine njodzi. Iyo inokoshesa hunhu hwakasiyana pamusoro pekapasita yekureba, ichitungamira iyo kuyera ipfupi, akawanda akasiyana mapassword akasimba kupfuura akareba, mashoma akasiyana mapassword. Icho kunyepa kunozopinza vashandisi vako mumatambudziko kana vakambotarisana nekutyisidzira kwakakomba.

    • 25

      Handibvumirani, Jorodhani! Muenzaniso wacho wakangoburitswa kunze semuenzaniso wechinyorwa. Kurudziro yangu kune vanhu ndeye kushandisa password yekushandisa chishandiso kugadzira yakazvimirira mapassifesi kune chero saiti yakasarudzika kwairi. Ndatenda!

  24. 26
  25. 27
  26. 28

    ndinonyatsokoshesa iwe wakatsvaga izvi kakawanda asi pakupedzisira ndakawana tsamba yako uye ndakanyatsogadziriswa. WAITA HAKO

  27. 29
  28. 31

Unofungei?

Nzvimbo iyi inoshandisa Akismet kuderedza spam. Dzidza kuti sei deta yako inoshandiswa.