|
@@ -385,6 +385,7 @@ def getKeyByCode(keyFile):
|
|
|
with open(keyFile, 'r') as file1:
|
|
|
reader = csv.reader(file1)
|
|
|
key = [int(row[0]) for index, row in enumerate(reader) if index>1]
|
|
|
+
|
|
|
halfKeyLen = len(key)//2
|
|
|
key=key[:halfKeyLen]
|
|
|
return key
|
|
@@ -422,27 +423,40 @@ def shiftchar(char0, shift):
|
|
|
return chr(ord(char0) + shift)
|
|
|
|
|
|
|
|
|
+from os import listdir
|
|
|
+
|
|
|
keyPath = 'keys/'
|
|
|
-key_p07 = getKeyByCode(keyPath+'key_p07.csv')
|
|
|
-
|
|
|
-with open('../../../db/ndg2.gat4/itxt/p07', 'rb') as file1:
|
|
|
- file1.seek(4)
|
|
|
- p07_enc = file1.read().decode(encoding="utf-32-le")
|
|
|
-
|
|
|
-print( decodeTextByKey(p07_enc[21:1000], key_p07, 21) )
|
|
|
-
|
|
|
-affa2==key_p07
|
|
|
-
|
|
|
-for i, entry in enumerate(affa2):
|
|
|
- print(i, entry==key_p07[i])
|
|
|
+itxtPath = '../../../db/ndg2.gat4/itxt/'
|
|
|
+
|
|
|
+files = listdir(keyPath)
|
|
|
+keyFiles = [file for file in files if (file.startswith('key_') and file.endswith('.csv'))]
|
|
|
+
|
|
|
+keys = {}
|
|
|
+files = {}
|
|
|
+for keyFile in keyFiles:
|
|
|
+ code = keyFile.replace('key_', '').replace('.csv', '')
|
|
|
+ try:
|
|
|
+ keys[code] = getKeyByCode(keyPath+keyFile)
|
|
|
+ with open('../../../db/ndg2.gat4/itxt/'+code, 'rb') as file1:
|
|
|
+ file1.seek(4)
|
|
|
+ files[code] = file1.read().decode(encoding="utf-32-le")
|
|
|
+ except:
|
|
|
+ pass
|
|
|
+
|
|
|
+codes = keys.keys()
|
|
|
|
|
|
-affamezzi=affa2[:166]
|
|
|
+import random
|
|
|
+
|
|
|
+decoded = {}
|
|
|
+for ind, code in enumerate(codes):
|
|
|
+ rand1 = random.randint(1, 15)
|
|
|
+ rand2 = random.randint(1, 15)+500
|
|
|
+ decoded[code] = decodeTextByKey(files[code][rand1:rand2], keys[code], rand1)
|
|
|
+ print(ind, code)
|
|
|
+ print(decoded[code])
|
|
|
+ print()
|
|
|
|
|
|
-print(affa2[166:])
|
|
|
+codes
|
|
|
|
|
|
-affamezzi==affa2[166:]
|
|
|
+decoded['fq']
|
|
|
|
|
|
-from os import listdir
|
|
|
-
|
|
|
-files = listdir(keyPath)
|
|
|
-keyFiles = [file for file in files if (file.startswith('key_') and file.endswith('.csv'))]
|