Theknoloji e Tsoelang PeleLi-CRM le Li-Platform tsa DataKhoebo ea Imeile le Iketsetse ea Papatso ea Imeile

Lekola Matla a Phasewete ka JavaScript le Litlhaloso tse Tloaelehileng (Ka Mehlala ea Mahlakore a Server, Haholo!)

Ke ne ke etsa lipatlisiso mabapi le ho fumana mohlala o motle oa mohlahlobi oa Matla a Netefete o sebelisang Javascript 'me Lipolelo tsa ka mehla (Regex). Ka ts'ebeliso mosebetsing oa ka, re ngola molaetsa ho netefatsa matla a phasewete mme ha ho bonolo ho basebelisi ba rona.

Regex ke eng?

Polelo e tloaelehileng ke tatellano ea litlhaku tse hlalosang paterone ea patlo. Hangata, lipaterone tse joalo li sebelisoa ke likhoele tsa ho batla li-algorithms bakeng sa fumana or fumana mme o nkele sebaka ts'ebetso ea likhoele, kapa bakeng sa netefatso ea ho kenya. 

Sengoloa sena ha se hlile ha se na ho u ruta lipolelo tse tloaelehileng. Tseba feela hore bokhoni ba ho sebelisa Lipolelo tsa Kamehla bo tla nolofatsa nts'etsopele ea hau ha o ntse o batla lipaterone tse ngotsoeng. Ho bohlokoa hape ho hlokomela hore lipuo tse ngata tsa nts'etsopele li ntlafalitse ts'ebeliso ea polelo e tloaelehileng… ho fapana le ho qhekella le ho batlisisa likhoele mohato ka mohato, Regex hangata e potlakile haholo ka lehlakoreng la seva le moreki.

Ke batlile marang-rang hanyane pele ke fumana mohlala tsa lipolelo tse tloaelehileng tse lulang li batla motsoako oa bolelele, litlhaku le matšoao. Leha ho le joalo, khoutu e ne e fetelletse tatso ea ka hanyane mme e etselitsoe .NET. Kahoo ke nolofalitse khoutu ebe ke e kenya ka JavaScript. Sena se etsa hore e netefatsa matla a phasewete ka nako ea 'nete ho sebatli sa moreki pele o e romella… hape e fana ka maikutlo ho mosebelisi ka matla a phasewete.

Tlanya A Password

Kotlo e 'ngoe le e' ngoe ea keyboard, phasewete e ea lekoa khahlano le polelo e tloaelehileng ebe ho fanoa ka maikutlo ho mosebelisi ka nako e tlasa eona.

Khoutu ke ena

The Lipolelo tsa ka mehla etsa mosebetsi o tsotehang oa ho fokotsa bolelele ba khoutu. Mosebetsi ona oa Javascript o lekola matla a phasewete le hore na ho folisa ho bonolo, ho bohareng, ho thata, kapa ho thata haholo ho hakanya. Ha motho a ntse a thaepa, e fana ka malebela a ho mo khothaletsa hore a be matla. E netefatsa password e ipapisitse le:

  • Length - Haeba bolelele bo le ka tlase kapa ho feta litlhaku tse 8.
  • Motsoako Case - Haeba phasewete e na le litlhaku tse holimo le tse tlase.
  • Numbers - Haeba phasewete e kenyelletsa linomoro.
  • Batho ba ikhethang - Haeba phasewete e kenyelletsa litlhaku tse ikhethang.

Mosebetsi o bonts'a bothata hammoho le malebela a ho thatafatsa phasewete ho feta.

function checkPasswordStrength(password) {
  // Initialize variables
  var strength = 0;
  var tips = "";

  // Check password length
  if (password.length < 8) {
    tips += "Make the password longer. ";
  } else {
    strength += 1;
  }

  // Check for mixed case
  if (password.match(/[a-z]/) && password.match(/[A-Z]/)) {
    strength += 1;
  } else {
    tips += "Use both lowercase and uppercase letters. ";
  }

  // Check for numbers
  if (password.match(/\d/)) {
    strength += 1;
  } else {
    tips += "Include at least one number. ";
  }

  // Check for special characters
  if (password.match(/[^a-zA-Z\d]/)) {
    strength += 1;
  } else {
    tips += "Include at least one special character. ";
  }

  // Return results
  if (strength < 2) {
    return "Easy to guess. " + tips;
  } else if (strength === 2) {
    return "Medium difficulty. " + tips;
  } else if (strength === 3) {
    return "Difficult. " + tips;
  } else {
    return "Extremely difficult. " + tips;
  }
}

Thatafatsa Your Password Kopo

Ho bohlokoa hore o seke oa netefatsa feela kaho ea phasewete ka har'a Javascript ea hau. Sena se ka thusa mang kapa mang ea nang le lisebelisoa tsa nts'etsopele ea sebatli hore a fete script 'me a sebelise phasewete efe kapa efe eo ba ka e ratang. U LOKELA ho sebelisa cheke-lehlakoreng ho netefatsa matla a phasewete pele ue boloka sethaleng sa hau.

Mosebetsi oa PHP Bakeng sa Matla a Phasewete

function checkPasswordStrength($password) {
  // Initialize variables
  $strength = 0;

  // Check password length
  if (strlen($password) < 8) {
    return "Easy to guess";
  } else {
    $strength += 1;
  }

  // Check for mixed case
  if (preg_match("/[a-z]/", $password) && preg_match("/[A-Z]/", $password)) {
    $strength += 1;
  }

  // Check for numbers
  if (preg_match("/\d/", $password)) {
    $strength += 1;
  }

  // Check for special characters
  if (preg_match("/[^a-zA-Z\d]/", $password)) {
    $strength += 1;
  }

  // Return strength level
  if ($strength < 2) {
    return "Easy to guess";
  } else if ($strength === 2) {
    return "Medium difficulty";
  } else if ($strength === 3) {
    return "Difficult";
  } else {
    return "Extremely difficult";
  }
}

Mosebetsi oa Python Bakeng sa Matla a Password

def check_password_strength(password):
  # Initialize variables
  strength = 0

  # Check password length
  if len(password) < 8:
    return "Easy to guess"
  else:
    strength += 1

  # Check for mixed case
  if any(char.islower() for char in password) and any(char.isupper() for char in password):
    strength += 1

  # Check for numbers
  if any(char.isdigit() for char in password):
    strength += 1

  # Check for special characters
  if any(not char.isalnum() for char in password):
    strength += 1

  # Return strength level
  if strength < 2:
    return "Easy to guess"
  elif strength == 2:
    return "Medium difficulty"
  elif strength == 3:
    return "Difficult"
  else:
    return "Extremely difficult"

Mosebetsi oa C # Bakeng sa Matla a Phasewete

public string CheckPasswordStrength(string password) {
  // Initialize variables
  int strength = 0;

  // Check password length
  if (password.Length < 8) {
    return "Easy to guess";
  } else {
    strength += 1;
  }

  // Check for mixed case
  if (password.Any(char.IsLower) && password.Any(char.IsUpper)) {
    strength += 1;
  }

  // Check for numbers
  if (password.Any(char.IsDigit)) {
    strength += 1;
  }

  // Check for special characters
  if (password.Any(ch => !char.IsLetterOrDigit(ch))) {
    strength += 1;
  }

  // Return strength level
  if (strength < 2) {
    return "Easy to guess";
  } else if (strength == 2) {
    return "Medium difficulty";
  } else if (strength == 3) {
    return "Difficult";
  } else {
    return "Extremely difficult";
  }
}

Mosebetsi oa Java Bakeng sa Matla a Phasewete

public String checkPasswordStrength(String password) {
  // Initialize variables
  int strength = 0;

  // Check password length
  if (password.length() < 8) {
    return "Easy to guess";
  } else {
    strength += 1;
  }

  // Check for mixed case
  if (password.matches(".*[a-z].*") && password.matches(".*[A-Z].*")) {
    strength += 1;
  }

  // Check for numbers
  if (password.matches(".*\\d.*")) {
    strength += 1;
  }

  // Check for special characters
  if (password.matches(".*[^a-zA-Z\\d].*")) {
    strength += 1;
  }

  // Return strength level
  if (strength < 2) {
    return "Easy to guess";
  } else if (strength == 2) {
    return "Medium difficulty";
  } else if (strength == 3) {
    return "Difficult";
  } else {
    return "Extremely difficult";
  }
}

Douglas Karr

Douglas Karr ke mothehi oa Martech Zone le setsebi se tsebahalang sa phetoho ya dijithale. Douglas o thusitse ho qala tse 'maloa tse atlehileng tse qalang tsa MarTech, o thusitse boitelong bo nepahetseng ba chelete e fetang $5 bilione ho reka le matsete a Martech, mme o ntse a tsoela pele ho qala sethala le lits'ebeletso tsa hae. Ke mothehi-'moho oa Highbridge, feme ea boeletsi ea phetoho ea dijithale. Douglas hape ke sengoli se hatisitsoeng sa tataiso ea Dummie le buka ea boetapele ba khoebo.

33 Comments

  1. KEA LEBOHA! KEA LEBOHA! KEA LEBOHA! Ke 'nile ka thetsa ka libeke tse 2 ka khoutu e matla ea password e tsoang liwebsaeteng tse ling le ho hula moriri oa ka. Ea hau e khuts'oane, e sebetsa joalo ka ha ke batla, 'me ho feta tsohle, ho bonolo hore moqapi oa javascript a ka e fetola! Ke ne ke batla ho nka qeto ea matla mme ke se lumelle poso ea foromo hore e ntlafatse phasewete ea mosebelisi ntle le haeba e kopana le teko ea matla. Khouto ya batho ba bang e ne e rarahane haholo kapa e sa sebetse hantle kapa ho hong. Kea u rata! XXXXX

  2. Lumela, pele ho tsohle ke leboha haholo ka boiteko ba hau, ke lekile ho sebelisa sena ka Asp.net empa ha se sebetse, ke sebelisa

    sebakeng sa tag, 'me ha ea ka ea sebetsa, litlhahiso leha e le life?!

  3. "P@s$w0rD" e bonts'a ka matla, leha e ne e tla robeha kapele ka tlhaselo ea dictionary…
    Ho sebelisa tšobotsi e joalo ho tharollo ea litsebi, ke lumela hore ho bohlokoa ho kopanya algorithm ena le tlhahlobo ea dictionnary.

  4. Mofuta ona oa "ho hlahloba matla" o isa batho tseleng e kotsi haholo. E ananela ho fapana ha litlhaku ho feta bolelele ba poleloana ea mantsoe, e leng se etsang hore e be le lintlha tse khuts'oane, tse fapaneng haholo tsa li-passwords tse matla ho feta li-passwords tse telele, tse fokolang tse fapaneng. Seo ke leshano le tla kenya basebelisi ba hau mathateng haeba ba ka tobana le ts'okelo e matla ea bosholu.

    1. Ha ke hanane, Jordane! Mohlala o behiloe feela e le mohlala oa script. Khothatso ea ka ho batho ke ho sebelisa sesebelisoa sa taolo ea li-password ho etsa li-passwords tse ikemetseng bakeng sa sebaka sefe kapa sefe se ikhethileng ho sona. Kea leboha!

  5. U mopholosi ea phelang! Ke ne ke arola likhoele ka ho le letšehali le bohareng mme ke nahana hore ho na le tsela e betere mme ka fumana sengoathoana sa khoutu ea hau ke sebelisa Regex. Ke ile ka khona ho sebetsana le eona bakeng sa sebaka sa ka sa marang-rang…Ha u tsebe hore na sena se thusitse hakae. Ke leboha haholo Douglas !!

U nahana eng?

Sebaka sena se sebelisa Akismet ho fokotsa spam. Ithute kamoo litlhaloso tsa hau li hlahang kateng.

Related Articles