浏览代码

Use temp directory for tempEncryptedFile creation

Signed-off-by: alperozturk <alper_ozturk@proton.me>
alperozturk 1 年之前
父节点
当前提交
c6c6460630
共有 1 个文件被更改,包括 4 次插入4 次删除
  1. 4 4
      app/src/main/java/com/owncloud/android/utils/EncryptionUtils.java

+ 4 - 4
app/src/main/java/com/owncloud/android/utils/EncryptionUtils.java

@@ -547,11 +547,11 @@ public final class EncryptionUtils {
         return Base64.decode(string, Base64.NO_WRAP);
     }
 
-    public static EncryptedFile encryptFile(Context context, File file, Cipher cipher) throws InvalidParameterSpecException {
-        File encryptedFile = new File(file.getAbsolutePath() + ".enc.jpg");
-        encryptFileWithGivenCipher(file, encryptedFile, cipher);
+    public static EncryptedFile encryptFile(Context context, File file, Cipher cipher) throws InvalidParameterSpecException, IOException {
+        File tempEncryptedFile = File.createTempFile(file.getName(), "", context.getCacheDir());
+        encryptFileWithGivenCipher(file, tempEncryptedFile, cipher);
         String authenticationTagString = getAuthenticationTag(cipher);
-        return new EncryptedFile(encryptedFile, authenticationTagString);
+        return new EncryptedFile(tempEncryptedFile, authenticationTagString);
     }
 
     public static String getAuthenticationTag(Cipher cipher) throws InvalidParameterSpecException {