-
-
Save irwins/03e4b082b40a0aa4cb27cb6d3153272e to your computer and use it in GitHub Desktop.
crypto challenge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$crypto1 = @" | |
g-25Retopc7- | |
hv1QnelbedEp | |
"@ | |
$crypto2 = @" | |
PkTr2sz2*cF- | |
raz7GuD4w6U# | |
gctK3E@Bt1aY | |
QPic%705ZvAe | |
W6jePRfpmI)H | |
y^LoowCnbJdO | |
Si9Mber#)ieU | |
*f2Z6MSh7VuD | |
5a(hsv8el1oW | |
ZO7lpKyJlDz$ | |
-jI@tT23Raik | |
q=F&wB6c%Hly | |
"@ | |
function Get-DecryptedMessage { | |
Param( | |
$message, | |
$index = 0, | |
$offset = 5 | |
) | |
$arr = @() | |
$string = $($message -split "`r`n") -join '' | |
Do { | |
$arr += $string[$index] | |
$arr += $string[$index + $offset] | |
$index = $index + $offset + 1 | |
} While( $index -lt $string.Length ) | |
$arr -join '' | |
} | |
Get-DecryptedMessage -message $crypto1 | |
#Brute force to figure out which pair is the winner | |
0..12 | | |
ForEach-Object{ | |
$index = $_ | |
0..12 | | |
ForEach-Object{ | |
$offset = $_ | |
"{0},{1} - {2}" -f $index,$offset, $(Get-DecryptedMessage -message $crypto2 -index $index -offset $offset) | |
} | |
} | |
#Winning pair 0,12 | |
Get-DecryptedMessage -message $crypto2 -index 0 -offset 12 |
Author
irwins
commented
Jun 29, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment