Just thought I'd share this little one-liner script, in case anyone needs to generate random passwords or something.
I've got that in a script "/jffs/scripts/make-random-string":
That spits out a 64 character string with a base64 character-set. If you want a shorter string, just pipe the output into "head -c n", like this, for a 12 character string:
And if you need a newline after the string:
Or, use "tail -c n" but allow one character for the newline. So to get a 12 character strings, use:
nb, "/proc/timer_list" counts nanoseconds starting at boot. Avoid using it immediately after booting. A better option for immediately after booting would be:
Adjust the "256" for more or less entropy, as needed.
Code:
openssl sha384 -binary < /proc/timer_list | openssl base64
Code:
#!/bin/sh
openssl sha384 -binary < /proc/timer_list | openssl base64
Code:
/jffs/scripts/make-random-string | head -c 12
Code:
/jffs/scripts/make-random-string | head -c 12 ; echo
Code:
/jffs/scripts/make-random-string | tail -c 13
Code:
head -c 256 /dev/urandom | openssl sha384 -binary | openssl base64
Last edited: