skip to content
Alvin Lucillo

Generating random 256-bit key as hex

/ 1 min read

Unlike yesterday’s base64 format of the random key, hex is more readable. For example, it’s used in ObjectIds or UUIDs, but MongoDB ObjectIDs are 12 bytes (24 hex chars), so they are shorter than 32-byte keys. In contrast, the example below is for generating a 32-byte key in hex format.

openssl rand -hex 32
1e97be9fc36b31018a176ea498558cfd379ed9099f1a9655cf659955d07066af