diff options
author | Reinier van der Leer <pwuts@agpt.co> | 2024-01-29 18:29:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-29 18:29:24 +0100 |
commit | 575be818ca1f7c644e2adf94c584772547141f55 (patch) | |
tree | abb052ae787b1107c9dff8fb4d86ee84842d515d /benchmark/agbenchmark/challenges/deprecated/code/1_password_generator/artifacts_out/password_generator.py | |
parent | Update ossf-scorecard.yml (diff) | |
parent | fix(agent/json_utils): Make `extract_dict_from_response` more robust (diff) | |
download | Auto-GPT-security/analysis-workflows-sandbox.tar.gz Auto-GPT-security/analysis-workflows-sandbox.tar.bz2 Auto-GPT-security/analysis-workflows-sandbox.zip |
Merge branch 'master' into security/analysis-workflows-sandboxsecurity/analysis-workflows-sandbox
Diffstat (limited to 'benchmark/agbenchmark/challenges/deprecated/code/1_password_generator/artifacts_out/password_generator.py')
-rw-r--r-- | benchmark/agbenchmark/challenges/deprecated/code/1_password_generator/artifacts_out/password_generator.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/benchmark/agbenchmark/challenges/deprecated/code/1_password_generator/artifacts_out/password_generator.py b/benchmark/agbenchmark/challenges/deprecated/code/1_password_generator/artifacts_out/password_generator.py new file mode 100644 index 000000000..514ec43a4 --- /dev/null +++ b/benchmark/agbenchmark/challenges/deprecated/code/1_password_generator/artifacts_out/password_generator.py @@ -0,0 +1,23 @@ +import random +import string + + +def generate_password(length: int) -> str: + if length < 8 or length > 16: + raise ValueError("Password length must be between 8 and 16 characters.") + + characters = string.ascii_letters + string.digits + string.punctuation + password = [ + random.choice(string.ascii_lowercase), + random.choice(string.ascii_uppercase), + random.choice(string.digits), + random.choice(string.punctuation), + ] + password += [random.choice(characters) for _ in range(length - 4)] + random.shuffle(password) + return "".join(password) + + +if __name__ == "__main__": + password_length = random.randint(8, 16) + print(generate_password(password_length)) |