Skip to content

Instantly share code, notes, and snippets.

@irwins

irwins/Get-DecryptedMessage.ps1 Secret

Created Jun 29, 2019
Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@irwins irwins commented Jun 29, 2019

image

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