forked from paulpierce34/Base64-Tool
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConvert-Base64.ps1
More file actions
31 lines (29 loc) · 1.01 KB
/
Convert-Base64.ps1
File metadata and controls
31 lines (29 loc) · 1.01 KB
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
## The purpose of this script is to encode/decode a string to/from base64
function Invoke-Base64StringEncode {
[CmdletBinding()]
param(
[Parameter(Mandatory, ValueFromPipeline, Helpmessage = "Specify a string to encode", Position = 1)]
[string[]]$EncodeText
)
process {
$Response = @{}
Foreach($Text in $EncodeText) {
$Response += @{[string]$Text = [Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($Text))}
}
return $Response
}
}
function Invoke-Base64StringDecode {
[CmdletBinding()]
param (
[Parameter(Mandatory, ValueFromPipeline, Helpmessage = "Specify a string to decode", Position = 1)]
[string[]]$DecodeText
)
process {
$Response = @{}
Foreach($Text in $DecodeText) {
$Response += @{[string]$DecodeText = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($EncodedText))}
}
return $Response
}
}