Created
February 1, 2019 14:26
-
-
Save melkael/d1ed421f6e7920901bf0e09d63711d72 to your computer and use it in GitHub Desktop.
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
func decoder(str string) string { | |
key := "" | |
best := "" | |
var max float32 = 0 | |
for i := 0x00; i < 0xFF; i++ { | |
key = fmt.Sprintf("%c", i) | |
decodedHex := xorStrToChar(str, key) | |
decodedAscii := hexToAscii(decodedHex) | |
if max < rateString(decodedAscii) { | |
max = rateString(decodedAscii) | |
best = decodedAscii | |
} | |
} | |
if max > 1.5 { | |
return best | |
} else { | |
return "" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment