import os, shutil, sys sys.path.insert(0, '/data/data/com.termux/files/home/local-testkit') import hermes_wechat_daemon as d d.load_config() src = d.config.get('db_src_path') # Test copy_db work1 = '/data/data/com.termux/files/home/hermes_work1' os.makedirs(work1, exist_ok=True) copied = d.copy_db(src, work1) print('copy_db:', copied) for f in copied: print(' ', f, os.path.getsize(f)) # Test shutil.copy work2 = '/data/data/com.termux/files/home/hermes_work2' if os.path.exists(work2): shutil.rmtree(work2) os.makedirs(work2, exist_ok=True) dst = os.path.join(work2, 'EnMicroMsg.db') shutil.copy(src, dst) print('shutil:', dst, os.path.getsize(dst)) # Test decrypt with copy_db file plain1 = '/data/data/com.termux/files/home/test1.db' if os.path.exists(plain1): os.remove(plain1) ok1 = d.decrypt_db(os.path.join(work1, 'EnMicroMsg.db'), plain1, d.config.get('sqlcipher_key'), 1024, 1) print('copy_db decrypt=', ok1, os.path.exists(plain1)) # Test decrypt with shutil file plain2 = '/data/data/com.termux/files/home/test2.db' if os.path.exists(plain2): os.remove(plain2) ok2 = d.decrypt_db(dst, plain2, d.config.get('sqlcipher_key'), 1024, 1) print('shutil decrypt=', ok2, os.path.exists(plain2))