this package can be used to encrypt/decrypt data in stream form (e.g. HTTP, IO,etc)
this package initially comes with a http client adapter for
example:final secureFile = SecureFile( File('example'), encrypter: encrypter, decrypter: decrypter, useBase64: true, maxBlockSize: 4096, );
de/encryption is done while read/writing meaning data will not be de/encrypted until that part of data is read/written.
both of de/encrypter use same method. Note: for internal encrypters like
AES,RSA,Gzip,NoEncryptionit has an assertion but if you extend De/Encrypter you need to test it inside your app. in some cases this may seems ok but in action during reading the file content may cause an error or even data corruption.
this does not extend
writemethods support appending to file. but in this case you need to pass a
EncryptStreamMetato constructor with
Endingwith same value using
EncryptStreamMeta.sameSeparatorAsEnding('....... separator .......').
due to high load of some algorithms during de/encryption this class does not support synchronous read/write.
methods in this class are not running inside an isolate and therefore may cause performance issues.
/// create instance of `CipherDioHttpAdapter` final dioClient = CipherDioHttpAdapter( decrypter: decrypter, encrypter: encrypter, ); /// creating an instance of `Dio` with `CipherDioHttpAdapter` final dio = Dio()..httpClientAdapter = dioClient;
in this method only the body of the request is encrypted.
in this method only the body of the response is decrypted.
the header of request is not encrypted. to deform the header of request, you can extend one of
IByteDataEncrypters and override the
alterHeadermethod to do so.
for backend side you can check example of this project
Example of De/Encrypter
to create instance of de/encrypterfinal encrypter = AESByteDataEncrypter.randomSecureKey(); final decrypter = AESByteDataDecrypter( key: encrypter.key, iv: encrypter.iv, );