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.

34 Comments

  1. 1
  2. 2

    WAZVIITA! WAZVIITA! WAZVIITA! Ndanga ndichinyengerera kwemavhiki maviri nemadamn password simba kodhi kubva kune mamwe mawebhusaiti uye nekudhonza bvudzi rangu kunze. Yako ipfupi, inoshanda sezvandinoda uye zvakanyanya kupfuura zvese, zviri nyore kuti javascript novice igadzirise! Ini ndaida kutora mutongo wesimba uye kusarega iyo fomu post kuti inyatso gadzirisa password yemushandisi kunze kwekunge yasangana nekuyedzwa kwesimba. Kodhi yevamwe vanhu yaive yakaoma kana isingashande kana zvimwewo. Ndinokuda! XXXXX

  3. 4

    tenda mwari kune vanhu vanogona kunyora chidimbu chekodhi nemazvo.
    Pane zvakaitika kuna Janis.

    Izvi zvinoshanda kunze kwebhokisi iro rakakwana kune vanhu vakaita seni vasingakwanise kodhi javascript!

  4. 5
  5. 6

    Mhoroi, chekutanga ndatenda zvikuru nekuedza kwenyu, ndakaedza kushandisa izvi neAsp.net asi hazvina kushanda, ndiri kushandisa

    pachinzvimbo che tag, uye haina kushanda, chero mazano?!

  6. 7

    KuNisreen: iyo kodhi mubhokisi rakasimbiswa haishande ne cut'n'paste. Iyo single quote yakakanganiswa. Iyo ratidziro yekubatanidza kodhi yakanaka zvakadaro.

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

    "P@s$w0rD" inoratidza yakasimba, kunyangwe yaizotsemuka nekukasira nekurwiswa kweduramazwi…
    Kuisa chinhu chakadaro pane professional solution, ndinotenda zvakakosha kubatanidza iyi algorithm nedictionnary cheki.

  11. 12
  12. 13

    Ndatenda neiyi kodhi diki ndinokwanisa kuishandisa iye zvino kuyedza simba repassword yangu kana vashanyi vangu .vapinza mapassword avo,

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

    mumwe munhu angataure here, nei isina kushanda yangu ..

    ndakakopa kodhi yese, uye ndiinamira kune notepad++, asi haishande zvachose?
    ndibatsireiwo..

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

    Rudzi urwu rwe "simba rekuongorora" rinotungamirira vanhu munzira ine ngozi zvikuru. Inokoshesa kusiyana kwehunhu pamusoro pehurefu hwezwi rekupinda, zvichiita kuti iite mapfupi, akasiyana mapassword akasimba kupfuura akareba, mashoma akasiyana mapassword. Ihwo hunyengeri huchaita kuti vashandisi vako vapinde mudambudziko kana vakambosangana nenjodzi yekubira.

    • 25

      Handipokane, Jorodhani! Muenzaniso wacho wakangoiswa kunze semuenzaniso wezvinyorwa. Kurudziro yangu kuvanhu ndeye kushandisa password management tool kugadzira yakazvimirira mapassword kune chero saiti yakasarudzika kwairi. Ndatenda!

  24. 26
  25. 27
  26. 28
  27. 29
  28. 31
  29. 33

    Iwe uri mupenyu saver! Ini ndanga ndichiparura tambo kuruboshwe kurudyi nepakati uye ndikafunga kuti pane nzira iri nani uye ndakawana chidimbu chako chekodhi uchishandisa Regex. Ndakakwanisa kuita manyemwe nayo kune yangu saiti…Hauzive kuti izvi zvakabatsira zvakadii. Thanks zvikuru Douglas!!

Unofungei?

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