Hacker News new | ask | show | jobs
by thinkingkong 2195 days ago
If you need a unique identifier on the command line there are a few ways to do it.

uuidgen is one. My personal favorite is this snippet.

$ id=$(openssl rand 1000 | openssl sha1) && printf "%s${id:0:8}\n"

1 comments

Why would you want to hash random bytes? The only thing you could theoretically achieve by that would be decreasing entropy. Just do openssl rand -hex 20 (or any other number of bytes as needed, or -base64 for another encoding).