Base64 conversion error

Asked

Viewed 82 times

0

Good morning I’m trying to convert a base string 64

$b = ((New-Object System.Net.WebClient).DownloadString("domain/file")

$c = [System.Convert]::FromBase64String($b)

but give me the error

Exception calling "FromBase64String" with "1" argument(s): "A entrada não é uma cadeia de Base-64 válida dado que
contém um caráter que não é de base 64, mais de dois carateres de preenchimento ou um caráter ilegal entre os
carateres de preenchimento. "
At line:1 char:1
+ $c = [System.Convert]::FromBase64String($b)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : FormatException

What could I be doing wrong?

Thank you

  • I did the test here and did not generate this exception, I believe the problem is present in the contents of variable $b.

  • the content you used was a PE or a bin?

  • It was a local string that I myself declared with Base64 content.

  • I tried to replace PE with PE in Base64 nor txt format but still does not give

  • The problem is with the data you are trying to convert from base64 for binary. Could attach the question.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.