-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathsolution1.ps1
42 lines (31 loc) · 836 Bytes
/
solution1.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
<#
Author: Doug Finke
Email: finked@hotmail.com
Blog: https://dfinke.github.io/
Twitter: https://twitter.com/dfinke
GitHub: https://github.com/dfinke
YouTube: https://www.youtube.com/dougfinke
PowerShell Meetup: https://www.meetup.com/NycPowershellMeetup/
LinkedIn: https://www.linkedin.com/in/douglasfinke/
#>
param(
[Parameter(Mandatory)]
$text,
$seed
)
if ($seed) { $null = Get-Random -SetSeed $seed }
if (Test-Path $text) { $text = Get-Content -Raw $text }
function choose {
param($char)
if (Get-Random -Minimum 0 -Maximum 2) {
[char]::ToUpper($char)
}
else {
[char]::ToLower($char)
}
}
$ransom = @()
foreach ($char in $text.ToCharArray()) {
$ransom += choose $char
}
-join $ransom