PowerShell | Encoding & Decoding (Base64)

PowerShell provides an easy method for Base64 encoding and decoding.


Encoding:

$pass="STENGE.info"
$encodePass=[System.Text.Encoding]::Unicode.GetBytes($pass)
$encodeStr=[Convert]::ToBase64String($encodePass)
$encodeStr

The result is this base64 encoded text:

UwBUAEUATgBHAEUALgBpAG4AZgBvAA==

Decoding:

$encodeStr="UwBUAEUATgBHAEUALgBpAG4AZgBvAA=="
$bytesData=[System.Convert]::FromBase64String($encodeStr)
$decodeValue=[System.Text.Encoding]::Unicode.GetString($bytesData)
$decodeValue

The result:

STENGE.info


And if you want to convert a file, it should look something like :

$fileName = "C:\usr\key.txt"
$fileContent = get-content $fileName
$fileContentBytes = [System.Text.Encoding]::Unicode.GetBytes($fileContent)
$fileContentEncoded = [System.Convert]::ToBase64String($fileContentBytes)
$fileContentEncoded | set-content ($fileName + ".b64")


40 views0 comments

Recent Posts

See All

LibreNMS

LibreNMS is an open source, powerful and feature-rich auto-discovering PHP based network monitoring system which uses the SNMP protocol. It supports a broad range of operating systems including Linux,

Vulmap – Web Vulnerability

Vulmap is a vulnerability scanning tool that can scan for vulnerabilities in Web containers, Web servers, Web middleware, and CMS and other Web programs, and has vulnerability exploitation functions.

Vigenere Cipher

Vigenere Cipher is a method of encrypting alphabetic text. It uses a simple form of polyalphabetic substitution. A polyalphabetic cipher is any cipher based on substitution, using multiple substitutio