Sample code for 30+ languages & platforms
PowerShell

Get Contents of File as Base64

See more Encryption Examples

Demonstrates how to read the contents of a file and convert to a base64 string.

Chilkat PowerShell Downloads

PowerShell
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"

$success = $false

$bd = New-Object Chilkat.BinData

$success = $bd.LoadFile("qa_data/jpg/starfish.jpg")
if ($success -eq $false) {
    $("Failed to load file.")
    exit
}

$($bd.GetEncoded("base64"))

# If you want mult-line base64:
$("--")
$($bd.GetEncoded("base64_mime"))

# If you want hex..
$("--")
$($bd.GetEncoded("hex"))

# etc.