How To Convert .pfx file to Base64 String in Windows Terminal

Mert Ilis
Oct 29, 2020

--

You can easily convert PKCS#12 pfx files to Base64 strings using the new Windows Terminal.

Windows Terminal includes Powershell Core and the following commands enable you to create the Base64 string of your certificate archive binary.

$fileContentBytes = get-content ‘C:\Certificates\Client.pfx’ -AsByteStream

This command creates a byte array of the binary pfx file.

[System.Convert]::ToBase64String($fileContentBytes) | Out-File ‘C:\Certificates\Client_Pfx_Base64.txt’

This command converts bytes to the Base64 string and writes it to the Client_Pfx_Base64.txt file.

Hope it helps!

--

--

Mert Ilis

I’m a software development enthusiast who likes trying different web technologies and adding value to his team.