You're viewing a comment by vignesh and its responses.

vignesh Permalink
March 08, 2015, 13:10

can anyone help me to write the shell script for password valudation...u should assume any five password criteria... (criteria like password length shold be more than 6 and any 4 other criteria)please...

Comment Responses

Anirudh Permalink
February 03, 2016, 11:12

Here's a barebones password validation routine template code which you can fashion per your policies. Note: the password to be validated is stored in a shell variable $passwd. YMMV.

printf '%s\n' "$passwd" |\
sed -e '
   ## password validation constraints(YMMV):
   # 1.  no whitespace
   # 2.  length >= 8
   # 3a. atleast 1 nonalpha
   # 3b. atleast 1 uppercase alpha
   # 3c. atleast 1 lowercase alpha

   /\s/bbad             # Coz, found a whitespace
   /.\{8\}/!bbad        # Coz, length < 8
   /[^a-z0-9A-Z_]/!bbad # Coz, not even 1 nonalpha present
   /[a-z]/!bbad         # Coz, not even 1 lowercase alpha present
   /[A-Z]/!bbad         # Coz, not even 1 uppercase alpha present

   # all clear


Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "antispam_95": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.