Generate random string for various use case

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==

About Amit Agarwal