solved the first 5 problems

This commit is contained in:
Joshua Flores 2025-04-26 22:37:02 -04:00
parent 5f28587c15
commit 8211d16af3
No known key found for this signature in database
GPG key ID: CE41E342DBBBB9B7
9 changed files with 8235 additions and 5 deletions

19
03.py Normal file
View file

@ -0,0 +1,19 @@
import helper, cryptlib
def main():
hexstring = helper.read_file("data/03.txt")
candidates = []
for key in range(256):
decrypt = cryptlib.single_byte_xor(hexstring, key)
english_score = cryptlib.score_english_lang(decrypt)
result = {
'key': key,
'score': english_score,
'plaintext': decrypt
}
candidates.append(result)
print(sorted(candidates, key=lambda c: c['score'], reverse=True)[0])
if __name__ == '__main__':
main()