55from tkinter import filedialog
66from tkinter .ttk import *
77
8+ from Crypto .Cipher import Blowfish
9+
10+ def chunks (l , n ):
11+ """Yield successive n-sized chunks from l."""
12+ for i in range (0 , len (l ), n ):
13+ yield l [i :i + n ]
14+
15+ def endianness_reversal (data ):
16+ return b'' .join (map (lambda x : x [::- 1 ],chunks (data , 4 )))
17+
18+ def CapcomBlowfish (file , key ):
19+ cipher = Blowfish .new (key .encode ("utf-8" ), Blowfish .MODE_ECB )
20+ return endianness_reversal (cipher .decrypt (endianness_reversal (file )))
21+
22+ def CapcomBlowfishEncrypt (file , key ):
23+ cipher = Blowfish .new (key .encode ("utf-8" ), Blowfish .MODE_ECB )
24+ return endianness_reversal (cipher .encrypt (endianness_reversal (file )))
25+
26+ file_keys = {
27+ ".dtt" :"hZ2H0gvUA4xIELjPoCIKefoCUFK9D77aPQvL9goKDpFbC2U2yhTRhWJG"
28+ }
29+
830def move_subspecies (monster_path : str , old_variant_id : int , new_variant_id : int ):
931 monster_path_name = os .path .basename (monster_path )
1032 lst = glob .glob (os .path .join (monster_path , "{0:02d}\\ **" .format (old_variant_id )), recursive = True )
@@ -17,6 +39,8 @@ def move_subspecies(monster_path : str, old_variant_id : int, new_variant_id : i
1739 if not os .path .isfile (filename ):
1840 continue
1941 aob = open (filename , 'rb' ).read ()
42+ if (os .path .splitext (filename )[1 ] in file_keys ):
43+ aob = CapcomBlowfish (aob , file_keys [os .path .splitext (filename )[1 ]])
2044 replacements = [
2145 (
2246 "em\\ {0}\\ {1:02d}" .format (monster_path_name , old_variant_id ),
@@ -57,6 +81,8 @@ def move_subspecies(monster_path : str, old_variant_id : int, new_variant_id : i
5781 local_filename = local_filename .replace (r , w )
5882 local_filename = f"{ new_variant_id :02d} " + local_filename [2 :]
5983 final_filename = os .path .join (monster_path , local_filename )
84+ if (os .path .splitext (filename )[1 ] in file_keys ):
85+ aob = CapcomBlowfishEncrypt (aob , file_keys [os .path .splitext (filename )[1 ]])
6086 os .makedirs (os .path .dirname (final_filename ), exist_ok = True )
6187 open (final_filename , 'wb' ).write (aob )
6288 progress .stop ()
0 commit comments