Skip to content

Instantly share code, notes, and snippets.

@logankilpatrick
Last active January 2, 2022 21:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save logankilpatrick/3825d60a86713534e4d8abf992dab7ba to your computer and use it in GitHub Desktop.
Save logankilpatrick/3825d60a86713534e4d8abf992dab7ba to your computer and use it in GitHub Desktop.
# Generate Passwords in Julia
# Source: https://github.com/logankilpatrick/10-Julia-Projects-for-Beginners
using ProgressBars
using Random
# WARNING: Do not use this code to generate actual passwords!
function generate_passwords()
num_passwords = parse(Int64, Base.prompt("How many passwords do you want to generate?"))
password_length = parse(Int64, Base.prompt("How long should each password be?"))
# Create an empty vector / array
password_holder = []
# Generate a progress bar to show how close we are to being done
for i in ProgressBar(1:num_passwords)
# Add the new password into the password holder
push!(password_holder, randstring(password_length))
sleep(0.2) # Manually slowdown the generation of passwords
end
# Only show the passwords if there are less than 100
if length(password_holder) <= 100
# Loop through each password one by one
for password in password_holder
print("\n", password)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment