QSL4A Documentation of
encryptFile <QSL4A API Menu>encryptFile( srcFile, dstFile )
Encrypt a File to another File,
needs to run droid.cipherInit first .
if you want to operate files in Media Storage Device or /sdcard/Android/data/<packagename> , run droid.documentTreeShowOpen first .
srcFile (String)
dstFile (String)
return None
===== ===== ===== =====
Example :
>>> from androidhelper import *
>>> droid = Android()
>>> droid.cipherInit('好好学习!!!!',encodingFormat='utf-8') # The above Chinese is 16 bytes after being encoded by UTF-8
Result(id=1, result=None, error=None)
>>> p = '/sdcard/!0/1.txt' # Replace with your plaintext file path
>>> q = '/sdcard/!0/2.enc' # Replace with your encrypted file path
>>> open(p,'wb').write(b'AbCd\x00\x01')
6
>>> droid.encryptFile(p,q)
Result(id=2, result=None, error=None)
>>> open(q,'rb').read() # Encryption Result will be different because of Random Initial Vector
b'\x91\x97\xd7\xa9\xd6\x93\xc1\xd1\x80\xfdm\x1e\xb0!\x1d\xc5'
>>> r = '/sdcard/!0/3.txt' # Replace with your decrypted file path
>>> droid.decryptFile(q,r)
Result(id=3, result=None, error=None)
>>> open(r,'rb').read()
b'AbCd\x00\x01'
===== ===== ===== =====