Skip to content

Instantly share code, notes, and snippets.

@irwins
Created June 29, 2019 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save irwins/03e4b082b40a0aa4cb27cb6d3153272e to your computer and use it in GitHub Desktop.
Save irwins/03e4b082b40a0aa4cb27cb6d3153272e to your computer and use it in GitHub Desktop.
crypto challenge
$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
@irwins
Copy link
Author

irwins commented Jun 29, 2019

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment