-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCipher.psm1
111 lines (99 loc) · 2.31 KB
/
Cipher.psm1
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
function Encyp
{
[CmdletBinding()]
param
(
$inputText
)
begin
{
$inp = $inputText
$inp = $inp.Replace(' ','')
$inp = $inp.ToLower()
}
process
{
$r = [math]::Sqrt($inp.Length)
$sutun = [math]::Floor($r)
$satir = [math]::Ceiling($r)
$i = 0
$a = @()
do
{
$a += ,$inp.Substring($i,$sutun)
$i = $i + $sutun
} While ( ( $i + $sutun ) -lt $inp.Length )
$a += ,$inp.Substring($i,$inp.Length - $i)
}
end
{
$t = ""
for ($k = 0; $k -le ($sutun-1); $k++)
{
for ($j = 0; $j -le ($satir -1); $j++)
{
$t = $t + $a[$j][$k]
}
$t = $t + " "
}
return $t
}
}
function Set-Cipher
{
[CmdletBinding()]
param
(
[ValidateSet('Easy','Medium','Hard')]$level
)
$inputText = Read-Host -Prompt "Give me something"
if ($level -eq "Easy")
{
$result = Encyp -inputText $inputText
return $result
}
elseif ($level -eq "Medium")
{
$result = Encyp -inputText $inputText
$result = Encyp -inputText $result
return $result
}
else {
$result = Encyp -inputText $inputText
$result = Encyp -inputText $result
$result = Encyp -inputText $result
return $result
}
}
function Get-CleanString
{
begin
{
$inp = Read-Host "Give Me Encode Text"
$inp = $inp.ToLower()
}
process
{
$data = @()
$result = ""
$inp.Split(" ") | ForEach-Object { $data += $_ }
$max = $data[0].Length
$totalElement = $data.Length
for ($i = 0; $i -le ($max - 1); $i++)
{
for ($j = 0; $j -le ($totalElement - 1 ); $j++)
{
$result = $result + $data[$j][$i]
}
}
}
end
{
return $result
}
}
# Export only the functions using PowerShell standard verb-noun naming.
# Be sure to list each exported functions in the FunctionsToExport field of the module manifest file.
# This improves performance of command discovery in PowerShell.
Export-ModuleMember -Function "Set-Cipher"
Export-ModuleMember -Function "Get-CleanString"