Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shell Exercise 03 - Random Password Generator #364

Closed
Tracked by #360
tungbq opened this issue Dec 25, 2023 · 13 comments · Fixed by #588
Closed
Tracked by #360

Shell Exercise 03 - Random Password Generator #364

tungbq opened this issue Dec 25, 2023 · 13 comments · Fixed by #588
Assignees
Labels

Comments

@tungbq
Copy link
Owner

tungbq commented Dec 25, 2023

Random Password Generator: Create a script that generates a random password of a specified length.
Similar to #361 #363

DoD:

@tungbq tungbq added help wanted Extra attention is needed good first issue Good for newcomers shell first-timers-only labels Dec 25, 2023
@alirafatartist
Copy link

with javascript or what?

@tungbq
Copy link
Owner Author

tungbq commented Jan 1, 2024

Hi @alirafatartist, with shell script please. Thank you

@alirafatartist
Copy link

alirafatartist commented Jan 1, 2024

Hi @alirafatartist, with shell script please. Thank you

i think you wanted it with javascript

but this is Chatgpt answer

#!/bin/bash

generate_password() {
  local length=$1
  local password=""

  for i in $(seq 1 $length); do
    # Generate a random byte and convert it to a printable ASCII character
    byte=$(od -An -N1 -i /dev/urandom | awk '{print $1}')
    char=$(echo $byte | awk '{printf "%c", $1}')
    password="${password}${char}"
  done

  echo "$password"
}

# Check if a length argument is provided
if [ -z "$1" ]; then
  echo "Usage: $0 <password_length>"
  exit 1
fi

# Get the password length from command line argument
password_length=$1

# Generate and print the random password
random_password=$(generate_password "$password_length")
echo "Random Password: $random_password"

@tungbq
Copy link
Owner Author

tungbq commented Jan 2, 2024

Thanks @alirafatartist this is for shell script initially - to help everyone on shell script practice, could you please open a Pull request to address this task?

@alirafatartist
Copy link

Thanks @alirafatartist could you please open a Pull request to address this task?

Do you mean make file with this code and make pull request to this repo

@tungbq
Copy link
Owner Author

tungbq commented Jan 2, 2024

Thanks @alirafatartist could you please open a Pull request to address this task?

Do you mean make file with this code and make pull request to this repo

Yes, that's right. And if you want to contribute to this repo 😍

@alirafatartist
Copy link

Thanks @alirafatartist could you please open a Pull request to address this task?

Do you mean make file with this code and make pull request to this repo

Yes, that's right. And if you want to contribute to this repo 😍

in any folder or what??

@tungbq
Copy link
Owner Author

tungbq commented Jan 2, 2024

@alirafatartist
Copy link

Under folder https://github.com/tungbq/devops-basic/tree/main/topics/shell/excercise/answers Please refer to #361 for reference

check it !

@tungbq
Copy link
Owner Author

tungbq commented Jan 6, 2024

This task is still not resolved, welcome other contributors

Copy link

github-actions bot commented Mar 6, 2024

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Mar 6, 2024
@Jonathanlemon
Copy link
Contributor

Hi @tungbq Can I tackle this?

@tungbq
Copy link
Owner Author

tungbq commented Apr 3, 2024

Hi @tungbq Can I tackle this?

Thank you @Jonathanlemon I've just assigned it to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants