Spaces:
Sleeping
Sleeping
File size: 957 Bytes
55401d6 |
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 |
function Hello-World {
Write-Host "Hello, World!"
}
function Xor-Encrypt {
param (
[string] $string,
[string] $key
)
$keyLength = $key.Length
$stringLength = $string.Length
$encryptedString = ""
for ($i = 0; $i -lt $stringLength; $i++) {
$encryptedString += [char]($string[$i] -bxor $key[$i % $keyLength])
}
return $encryptedString
}
function Xor-Decrypt {
param (
[string] $string,
[string] $key
)
$keyLength = $key.Length
$stringLength = $string.Length
$decryptedString = ""
for ($i = 0; $i -lt $stringLength; $i++) {
$decryptedString += [char]($string[$i] -bxor $key[$i % $keyLength])
}
return $decryptedString
}
Hello-World
$encrypted = Xor-Encrypt -string "Hello, World!" -key "key"
Write-Host $encrypted
$decrypted = Xor-Decrypt -string $encrypted -key "key"
Write-Host $decrypted
|