Research breakthrough possible @S-Logix pro@slogix.in

Office Address

Social List

How to validate strength of a password using regular expression in R?

Description

To validate strength of a password using regular expression in R

Process

  Load the password

  If the password is less than 8 characters then declare the password as weak

  If the password is greater than 8 characters and contains one upper case letter or one lower case letter and contains only one digit then declare the password as Medium

  If the password is greater than 8 characters and contains more than one upper case letter or more than one lower case letter and contains more than one digit then declare the password as Strong

Sapmle Code

pw=readline(prompt = “Enter the password : “)
if (nchar(pw)<8) { cat(“Password Strength is weak\n”) }else if((nchar(pw)>8)&((length(unlist(regmatches(pw,gregexpr(“[A-Z]”,pw))))==1)|
(length(unlist(regmatches(pw,gregexpr(“[a-z]”,pw))))==1))&
(length(unlist(regmatches(pw,gregexpr(“[[:digit:]]”,pw))))==1))
{
cat(“Password strength is medium\n”)
}else if((nchar(pw)>8)&((length(unlist(regmatches(pw,gregexpr(“[A-Z]”,pw))))>1)|
(length(unlist(regmatches(pw,gregexpr(“[a-z]”,pw))))>1))&
(length(unlist(regmatches(pw,gregexpr(“[[:digit:]]”,pw))))>1)&
(length(unlist(regmatches(pw,gregexpr(“[~!@#$%^&*_+]”,pw))))>=1))
{
cat(“Password strength is Strong\n”)
}

Screenshots
validate strength of a password using regular expression in R
To validate strength of a password using regular expression in R
If the password is less than 8 characters then declare the password as weak
password is less than 8 characters then declare the password as weak