Skip to content

Commit

Permalink
added base64-conversion.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaseFlorell committed Mar 13, 2013
1 parent abbe699 commit a4b2efa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
14 changes: 14 additions & 0 deletions base64-conversion.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function Base64-Encode($string) {
$bytes = [System.Text.Encoding]::UTF8.GetBytes($string);
$encoded = [System.Convert]::ToBase64String($bytes);

return $encoded;
}


function Base64-Decode($string) {
$bytes = [System.Convert]::FromBase64String($string);
$decoded = [System.Text.Encoding]::UTF8.GetString($bytes);

return $decoded;
}
20 changes: 9 additions & 11 deletions send-an-email.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
Function Send-EMail {
# Requires 'base64-conversion.ps1'
$ScriptDirectory = Split-Path $MyInvocation.MyCommand.Path
. (Join-Path $ScriptDirectory base64-conversion.ps1)




Function Send-EMail {
Param (
[Parameter(Mandatory=$true)]
[String]$EmailTo,
Expand Down Expand Up @@ -27,20 +34,11 @@

} #End Function Send-EMail

function Base64-Decode($string) {
$bytes = [System.Convert]::FromBase64String($string);
$decoded = [System.Text.Encoding]::UTF8.GetString($bytes);

return $decoded;
}



Send-EMail -EmailFrom "[email protected]"`
-EmailTo "[email protected]"`
-Body "Test Body"`
-Subject "Test Subject"`
-Password (Base64-Decode "SGVsbG8gV29ybGQ=") # This isn't "secure" but at least it's not plain text.

# To get the Base64 representation of your password, just go to
# http://www.opinionatedgeek.com/dotnet/tools/base64encode/
# http://www.opinionatedgeek.com/dotnet/tools/base64encode/

0 comments on commit a4b2efa

Please sign in to comment.