Jump to content
Fórum Script Brasil
  • 0
Sign in to follow this  
Thiago André Cardoso

Algoritmo de verificação de senha

Question

/*

* ----------Valid PassWord----------

* PassWord must contain:

* At least SIX characters

* At least ONE character Caps lock

* At least ONE character lowerCase

* At least ONE number

* And Can not contain SPACE

*/

let password = "Doctor_Who_98"

var contain_space = 0

var contain_latters_lowerCase = 0

var contain_latters_capsLock = 0

var contain_number = 0

var number_character = 0

// up all the counters zeroed

let latters_lowerCase = "abcdefghijklmnopqrstyvxzy"

let latters_capsLock = "ABCDEFGHIJKLMNOPQRSTUVXZY"

let numbers = "0123456789"

for check_password in password { //will scroll through all the characters of the password

    number_character += 1 //Count the amount of character

    if check_password == " " {

        contain_space += 1 //check if there is any space

    }

    for check_latters_lowerCase in latters_lowerCase {

        if check_password == check_latters_lowerCase {

            contain_latters_lowerCase += 1 //Count the lowercase letters

        }

    }

    for check_latters_capsLock in latters_capsLock {

        if check_password == check_latters_capsLock {

            contain_latters_capsLock += 1 //Count the capslock letters

        }

    }

    for check_numbers in numbers {

        if check_password == check_numbers {

            contain_number += 1 //Count the number of numbers

        }

    }

}

if contain_space == 0 && contain_number > 0 && contain_latters_lowerCase > 0 && contain_latters_capsLock > 0 && number_character >= 6{

    print("Password OK")

} else {

    print("Invalid Password")

}

// Twitter: @thiagoandreqi

// Instagram: alfacexburger

 

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  



  • Forum Statistics

    • Total Topics
      148593
    • Total Posts
      644302
×
×
  • Create New...