How to get a random string of 32 hexadecimal digits through command line?

If you have hexdump then:

hexdump -vn16 -e'4/4 "%08X" 1 "\n"' /dev/urandom

should do the job.

Explanation:

  • -v to print all data (by default hexdump replaces repetition by *).
  • -n16 to consume 16 bytes of input (32 hex digits = 16 bytes).
  • 4/4 "%08X" to iterate four times, consume 4 bytes per iteration and print the corresponding 32 bits value as 8 hex digits, with leading zeros, if needed.
  • 1 "\n" to end with a single newline.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)