2

I'm creating an auth keyfile for mongodb and one way to do that is using: /usr/bin/openssl rand -base64 741 > $TMPFILE

I want to understand what is going on, I understood everything minus the meaning of three numbers 741

I couldn't find an explanation in the documentation.

muru
  • 197,895
  • 55
  • 485
  • 740
danilo
  • 1,385

1 Answers1

7

It means it will use 741 bytes of random data and base64 it.

Example with -hex 20 as this will be 40 long.

$ /usr/bin/openssl rand -hex 20
51b40b347dfccefa9b4f8a13d36c4564760c2f82

It is explained in the man page. See num at the end and the description:

SYNOPSIS
       openssl rand [-help] [-out file] [-rand file...]  [-writerand file]
       [-base64] [-hex] num

DESCRIPTION This command generates num random bytes using cryptographically secure pseudo random number generator (CSPRNG).

Rinzwind
  • 299,756