Log encryption and decryption times

This commit is contained in:
Vishnu Mohandas 2020-09-25 14:28:48 +05:30
parent 739c377a76
commit d362c7286e
2 changed files with 16 additions and 1 deletions

View file

@ -80,7 +80,7 @@ class Configuration {
}
String getHttpEndpoint() {
return "https://api.staging.ente.io";
return "http://192.168.0.100";
}
Future<void> setEndpoint(String endpoint) async {

View file

@ -41,8 +41,10 @@ class FileUploader {
});
}
// TODO: Remove encryption and decryption time logging
Future<File> encryptAndUploadFile(File file) async {
_logger.info("Uploading " + file.toString());
final password = CryptoUtil.getSecureRandomString(length: 32);
final iv = CryptoUtil.getSecureRandomBytes(length: 16);
final base64EncodedIV = base64.encode(iv);
@ -53,6 +55,10 @@ class FileUploader {
final encryptedFileName = file.generatedID.toString() + ".aes";
final tempDirectory = Configuration.instance.getTempDirectory();
final encryptedFilePath = tempDirectory + encryptedFileName;
_logger.info("File size " +
(await (await file.getAsset()).file).lengthSync().toString());
final encryptionStartTime = DateTime.now().millisecondsSinceEpoch;
if (file.fileType == FileType.image) {
await CryptoUtil.encryptDataToFile(
await getBytesFromDisk(file), encryptedFilePath, password);
@ -62,6 +68,15 @@ class FileUploader {
encryptedFilePath,
password);
}
final encryptionStopTime = DateTime.now().millisecondsSinceEpoch;
_logger.info("Encryption time: " +
(encryptionStopTime - encryptionStartTime).toString());
final decryptionStartTime = DateTime.now().millisecondsSinceEpoch;
await CryptoUtil.decryptFileToData(encryptedFilePath, password);
final decryptionStopTime = DateTime.now().millisecondsSinceEpoch;
_logger.info("Decryption time: " +
(decryptionStopTime - decryptionStartTime).toString());
final fileUploadURL = await getUploadURL();
String fileObjectKey =