The JS functionf to encode string to base64 (btoa()) or to decode base64 string (atob()) are not supported in PAM.
You can create these functions yourself and use it. Or you can use powershell to encode the file if you are on a Windows Server.
Encoding :
$Text = ‘This is a secret and should be hidden’
$Bytes = [System.Text.Encoding]::Unicode.GetBytes($Text)
$EncodedText =[Convert]::ToBase64String($Bytes)
Decoding :
$EncodedText = “VABoAGkAcwAgAGkAcwAgAGEAIABzAGUAYwByAGUAdAAgAGEAbgBkACAAcwBoAG8AdQBsAGQAIABiAGUAIABoAGkAZABlAG4A”
$DecodedText = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($EncodedText))
$DecodedText
And if you want to convert a file, it should look something like :
$fileName = "File1.txt"
$fileContent = get-content $fileName
$fileContentBytes = [System.Text.Encoding]::UTF8.GetBytes($fileContent)
$fileContentEncoded = [System.Convert]::ToBase64String($fileContentBytes)
$fileContentEncoded set-content ($fileName + ".b64")
Code snippet are not from me but from various websites. I did not test them.
Hope this helps.