Build a password generator

A password is only as strong as the randomness behind it. This set covers why the shell number $RANDOM will not do, what is subtly wrong with the common /dev/urandom pipeline, and how the finished genpass.sh works out the entropy of a password from its length and its alphabet.

4 questions 1 task Read the lesson

Questions

Each one is marked as you go, and the explanation arrives straight after, which is the part worth reading.

4 questions, marked as you go.

1 Why is $RANDOM a poor source for a password?
2 What is subtly wrong with tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 20 ?
3 A twenty character password drawn from 62 letters and digits carries roughly how many bits of entropy?
4 In the finished script, why are bytes at or above the limit thrown away rather than used straight away?

Tasks

These need your own device. Run the command in Termux, then paste what it printed. The marking looks at what the output means, so spacing, version numbers and ordering do not matter. If you have not installed anything yet, the lesson covers the setup.

Run the generator you built

The genpass.sh you finished in the last lesson is already saved next to you. This runs it for a twenty character password drawn from lower case, upper case and digits, and prints the password and its entropy on one line. Paste that line.

Run this in Termux On your own device. Nothing on this page executes it. The command runs in your terminal, and this box only reads what you paste back.

bash genpass.sh -l 20 -c lud
Marking your own work Both halves of this are checked in your browser, with no server involved, so nothing stops you from pasting output you did not run. The tasks are written so that the easiest way to pass one is to actually do it and read the result, which is the whole intention.

All sets Read the lesson