How to generate a random token on your local machine? | Vishal Chandra

Post

editor-img
Vishal Chandra
Sept 22, 2022

How to generate a random token on your local machine?

# Best option for a token:

export TOKEN=$(openssl rand -base64 64)

# Fallback for no openssl, on a Linux host:

export TOKEN=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 64)

# Failing that, then try:

export TOKEN=$(head -c 64 /dev/urandom|shasum| cut -d - -f 1)

Then view your token by echo $TOKEN


Checkout related posts on: