Duba Passarfin Kalmar wucewa tare da JavaScript da Maganganu na yau da kullun

Duba Passarfin Kalmar wucewa tare da JavaScript da Maganganu na yau da kullun
Lokacin Karatu: 2 minutes

Na kasance ina yin bincike kan gano kyakkyawan misali na mai duba Starfin Kalmar wucewa wanda ke amfani JavaScript da kuma Bayanin yau da kullun (Regex). A cikin aikace-aikacen a aikina, muna yin post don tabbatar da ƙarfin kalmar sirri kuma yana da matukar wahala ga masu amfani da mu.

Menene Regex?

Magana ta yau da kullun jerin haruffa ne waɗanda ke bayyana tsarin bincike. Yawancin lokaci, ana amfani da irin waɗannan alamu ta hanyar bincika algorithms don kirtani samu or nemo kuma ka maye gurbinsa aiki a kan kirtani, ko don ingancin shigarwa. 

Tabbas wannan labarin bazai koya muku maganganu na yau da kullun ba. Kawai san cewa ikon amfani da Maganganu na yau da kullun zai sauƙaƙe ci gaban ku yayin bincika samfuran rubutu. Yana da mahimmanci a lura cewa yawancin harsunan ci gaba sun inganta amfani da maganganu na yau da kullun… don haka maimakon yin lafazi da bincika kirtani mataki-mataki, Regex yawanci yafi sauri sabar da kuma abokin ciniki.

Na bincika yanar gizo kadan kafin na samu misali na wasu Manyan maganganu na yau da kullun waɗanda ke neman haɗin tsayi, haruffa, da alamu. Ta yaya, lambar ta ɗan wuce kima don ɗanɗano kuma an tsara ta don .NET. Don haka sai na sauƙaƙa lambar kuma na sanya ta a cikin JavaScript. Wannan yana sanya shi inganta ingancin kalmar sirri a ainihin lokacin akan burauz ɗin mai buƙata kafin sanya shi a baya… kuma yana ba da martani ga mai amfani akan ƙarfin kalmar sirri.

Rubuta Kalmar wucewa

Tare da kowane bugun faifan maɓallin, ana gwada kalmar sirrin akan magana ta yau da kullun sannan kuma ana ba da amsa ga mai amfani a cikin tazara a ƙarƙashinta.




Rubuta Kalmar wucewa

Ga Code din

The Bayanin yau da kullun yi kyakkyawan aiki na rage girman lambar:

  • Karin haruffa - Idan tsawon yana kasa da haruffa 8.
  • rauni - Idan tsayin bai wuce haruffa 10 ba kuma baya dauke da hadewar alamomi, iyakoki, rubutu.
  • Medium - Idan tsayin ya zama haruffa 10 ko sama da haka kuma yana da alamun alamomi, iyakoki, rubutu.
  • Strong - Idan tsawon haruffa 14 ne ko sama da haka kuma yana da alamun alamomi, iyakoki, rubutu.

<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>

Eningaddamar da Buƙatar Kalmar Ku

Yana da mahimmanci cewa ba kawai ku inganta ginin kalmar sirri a cikin Javascript ba. Wannan zai taimaka wa duk wanda ke da kayan aikin burauza su iya tsallake rubutun kuma suyi amfani da duk kalmar sirri da suke so. Yakamata Kullum kayi amfani da rajistar uwar garke don inganta ƙarfin kalmar sirri kafin adana ta a cikin dandalinku.

32 Comments

  1. 1
  2. 2

    NA GODE! NA GODE! NA GODE! Na kasance ban taɓa yin wauta ba har tsawon makonni 2 tare da ƙaƙƙarfan lambar ƙarfi ta kalmar sirri daga wasu rukunin yanar gizo kuma ina cire gashina. Naku gajere ne, yana aiki kamar yadda nakeso kuma mafi kyawun duka, mai sauƙi ne don sabon javascript ya gyara! Ina so in kama hukuncin ƙarfi kuma kada in bari sigar ta buga don sabunta kalmar sirri ta mai amfani sai dai idan ta haɗu da gwajin ƙarfi. Lambar wasu mutane ta kasance mai rikitarwa ko ba ta aiki daidai ko wani abu dabam. Ina son ku! XXXX

  3. 4

    na gode wa Allah don mutanen da za su iya rubuta ainihin lambar yadda ta dace.
    Shin yana da kwarewa kamar Janis.

    Wannan yana aiki daidai daga akwatin wanda yake cikakke ga mutane kamar ni waɗanda ke iya jan lambar javascript!

  4. 5
  5. 6

    Barka dai, da farko na gode sosai saboda kokarin ka, nayi kokarin amfani da wannan tare da Asp.net amma banyi aiki ba, ina amfani

    maimakon tag, kuma bai yi aiki ba, wani shawarwari?!

  6. 7

    Zuwa Nisreen: lambar da ke cikin akwatin da aka haskaka ba ya aiki tare da cut'n'paste. Kudin guda daya ya baci. Lambar hanyar haɗin zanga-zangar tana da kyau duk da haka.

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

    “P @ s $ w0rD” yana nuna da karfi, kodayake za a fasa shi da sauri tare da harin ƙamus attack
    Don ƙaddamar da irin wannan fasalin a kan ƙwararren masani, na yi imanin yana da mahimmanci a haɗa wannan algorithm ɗin tare da kundin ƙamus.

  11. 12
  12. 13

    Godiya ga wannan karamar lambar da zan iya amfani da ita yanzu don gwada ƙarfin kalmar sirri lokacin da baƙi na. Suka shigar da kalmomin shiga,

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

    wani zai iya fada, me yasa bai yi aiki ba nawa ..

    Na kwafe duk lambar, kuma na lika shi zuwa notepad ++, amma ba ya aiki kwata-kwata?
    don Allah a taimake ni ..

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

    Wannan nau'in "mai duba ƙarfi" yana kai mutane ga hanya mai haɗari sosai. Yana darajar darajar bambancin hali akan tsawon fassarar, wanda ke jagorantar shi zuwa gajera gajarta, kalmomin shiga daban daban waɗanda suka fi ƙarfi fiye da tsayi, ƙananan kalmomin shiga daban. Wannan karya ce wacce za ta sa masu amfani da ku cikin matsala idan har suka taba fuskantar mummunar barazanar satar bayanai

    • 25

      Ban yarda ba, Jordan! Misali kawai aka fitar dashi azaman misalin rubutun. Shawarata ga mutane ita ce amfani da kayan aikin sarrafa kalmar sirri don ƙirƙirar kalmomin sirri masu zaman kansu ga kowane rukunin yanar gizo wanda ya kebanta da shi. Godiya!

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

Me kuke tunani?

Wannan shafin yana amfani da Akismet don rage spam. Koyi yadda aka sarrafa bayanan bayaninka.