0

I need to use a command line on Windows OS to generate the base64 data of a specific file on the screen (without generating a file).

I have see that on Unix system is sufficient to use

cat <file_name>| base64

to obtain the file's contents encoded as base64.

On Windows I'm not able to have the same result.

I have found this solution:

certutil -encode -f <file_name> tmp.b64 && findstr /v /c:- tmp.b64 && del tmp.b64

But this needs the system to generate a temporary file and so, at the end, go to destroy it. With just the certutil command, the result on the screen is contaminated by 3 lines which contain unrelated information.

Could someone help me to provide a command on Windows that produces only the base64 data?

UPDATE: I have improved the result on the screen, by this new version of the command:

certutil -encode -f <file_name> tmp.b64 && cls && findstr /v /c:- tmp.b64 && del tmp.b64

The result is more like my requirement, but I would like to avoid creating the temporary file tmp.b64 every time.

Vincenzo
  • 41
  • 6

1 Answers1

0

I suggest to install OpenSSL on your Windows machine. After you set the PATH variable it's easy as:

type <file_name> | openssl base64
O.M.N.L
  • 151
  • 7
  • Hi, Unfortunatlly I haven't the possibility to install oher application on the server – Vincenzo Jan 05 '21 at 11:09
  • Changed to `type` for whatever reason – O.M.N.L Jan 05 '21 at 12:34
  • That's pretty marginal but who knows if the wretchedness that is Windows requires it. The usual recommendation is to use redirection if the command doesn't simply accept a file name argument. – tripleee Jan 05 '21 at 13:56
  • But with "more" or with "type", i could see the content on a file. My idea was to does not create a temporary file, but have the base64 of a specific file like result to a command. – Vincenzo Jan 05 '21 at 14:03