index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
author | komeil Parseh <ahmdparsh129@gmail.com> | 2022-02-28 18:03:09 +0330 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-28 15:33:09 +0100 |
commit | 7e19bf6e2ec2101b590405e6860007309661872b (patch) | |
tree | 6864d01593454efa14ec03aa01bf6f6ac06f9d58 /archinstall/lib | |
parent | f06aabb4d4a50d3a8ab7c07bef8390f72b091293 (diff) |
-rw-r--r-- | archinstall/lib/user_interaction.py | 32 |
diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index ddd388dc..aaf57143 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -99,20 +99,46 @@ def do_countdown() -> bool: return True +def check_password_strong(passwd :str) -> bool: + + symbol_count = 0 + if any(character.isdigit() for character in passwd): + symbol_count += 10 + if any(character.isupper() for character in passwd): + symbol_count += 26 + if any(character.islower() for character in passwd): + symbol_count += 26 + if any(not character.isalnum() for character in passwd): + symbol_count += 40 + + if symbol_count ** len(passwd) < 10e20: + + prompt = _("The password you are using seems to be weak,") + prompt += _("are you sure you want to use it?") + + choice = Menu(prompt, ["yes", "no"], default_option="yes").run() + return choice == "yes" + + return True + def get_password(prompt :str = '') -> Optional[str]: if not prompt: prompt = _("Enter a password: ") while passwd := getpass.getpass(prompt): + + if len(passwd.strip()) <= 0: + break + + if not check_password_strong(passwd): + continue + passwd_verification = getpass.getpass(prompt=_('And one more time for verification: ')) if passwd != passwd_verification: log(' * Passwords did not match * ', fg='red') continue - if len(passwd.strip()) <= 0: - break - return passwd return None |