Generate random string for various use case

2016-08-08 90 words 1 min read

Some times I need random string, for example to use as email seperator or to use in some API. One way is to use tools like /dev/[u]random or od and other such. But they seem cubersome after I figured this out.

openssl rand <length>
openssl rand 10

This alone without some parameters is not interesting thoug. You can use ‘-base64’ or ‘-hex’ to select the encoding.

So if you execute the above you will get something like this

$ openssl rand -hex 10
591e96110af8aecb760b

$ openssl rand -base64 10
TnuUXuiZXv2ktw==

author

Authored By Amit Agarwal

Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.

We notice you're using an adblocker. If you like our webite please keep us running by whitelisting this site in your ad blocker. We’re serving quality, related ads only. Thank you!

I've whitelisted your website.

Not now
This website uses cookies to ensure you get the best experience on our website. Learn more Got it