Skip to content

Comment on All My Exes Live in Texts

Comments

Damn, was hoping this was an article about how to encode Windows executables into text.

Ask and ye shall receive (in powershell form):

    $fName = "last.exe"

    $fContent = get-content $fName

    $fContentBytes = [System.Text.Encoding]::UTF8.GetBytes($fContent)

    $fContentEncoded = [System.Convert]::ToBase64String($fContentBytes)

    $fContentEncoded set-content ($fName + ".text")
Now you can at least say that all your .exes live in base64-encoded .texts.

I guess that should rather be

    Get-PSDrive -PSProvider Filesystem |
      Get-ChildItem -Recurse -Path { $_.Root } -Filter *.exe |
      ForEach-Object {
        $bytes = Get-Content $_ -Encoding Byte -ReadCount 0
        $text = [Convert]::ToBase64String($bytes)
        $text | Set-Content ($_.FullName + '.text')
      }
Reading the files as UTF-8 and converting them back into a byte array isn't such a great idea, I think ;-)

Thanks, upvoted. (But, also, note that I wasn't really hoping this was an article about how to store my Windows .exes as text :-)

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.