Search code examples
passwordsmit-scratch

How to make a Password Validator in Scratch


So I am trying to make a password validator in Scratch where it asks the user to input an answer and then it puts the answer through some criterias and then outputs if it is a valid password or not. The criterias are:

Has at least 8 characters, Has at least one uppercase letter, Has at least one lowercase letter, Has at least one number, Has at least one special character, Must contain less than 18 characters.

I tried to make a list first with all the different characters and check if the password contained them, but it doesn't actually work. I looked all over the internet for help on this but no one seems to have done it. The Scratch Wiki does have some stuff about case sensitivity but I haven't really been able to implement it. I really need help and I have been trying for a while now. Thanks.


Solution

  • If you just check if the password contains the list, it will only work if it has every single character of the list in order. If you want to make sure it contains each check, you're probably going to have to make a system that checks each letter for every check, which is a little complex.

    Check if <lowercase letter/whatever check> contains(letter(text reading #) of (password))

    If it passes this check, continue to the next check and set text reading # to 1. Otherwise, change text reading # by 1.

    I assume you'll know how to code this properly, but I just partially phrased in the way a normal human would.

    This will repeat until either it reaches the end of the password or it passes the check. it will then do this again, but for a different check. It's hard to explain in text, and this is my first answer, but I hope it helps.