This repository has been archived by the owner on Jul 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 134
/
ConvertFrom-Base64.ps1
56 lines (44 loc) · 1.58 KB
/
ConvertFrom-Base64.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
###############################################################################################################
# Language : PowerShell 4.0
# Filename : ConvertFrom-Base64.ps1
# Autor : BornToBeRoot (https://github.com/BornToBeRoot)
# Description : Convert a Base64 encoded string to a plain text string
# Repository : https://github.com/BornToBeRoot/PowerShell
###############################################################################################################
<#
.SYNOPSIS
Convert a Base64 encoded string to a plain text string
.DESCRIPTION
Convert a Base64 encoded string to a plain text string.
.EXAMPLE
ConvertFrom-Base64 -Text "UwBlAHQALQBMAG8AYwBhAHQAaQBvAG4AIAAtAFAAYQB0AGgAIAAiAEUAOgBcAFQAZQBtAHAAXABGAGkAbABlAHMAXAAiADsARwBlAHQALQBDAGgAaQBsAGQASQB0AGUAbQA="
Set-Location -Path "E:\Temp\Files\";Get-ChildItem
.LINK
https://github.com/BornToBeRoot/PowerShell/blob/master/Documentation/Function/ConvertFrom-Base64.README.md
#>
function ConvertFrom-Base64
{
[CmdletBinding()]
param(
[Parameter(
Mandatory=$true,
Position=0,
HelpMessage='Base64 encoded string, which is to be converted to an plain text string')]
[String]$Text
)
Begin{
}
Process{
try{
# Convert Base64 to bytes
$Bytes = [System.Convert]::FromBase64String($Text)
# Convert Bytes to Unicode and return it
[System.Text.Encoding]::Unicode.GetString($Bytes)
}
catch{
throw
}
}
End{
}
}