Skip to content
This repository has been archived by the owner on Nov 4, 2023. It is now read-only.

Commit

Permalink
移除 存档加密
Browse files Browse the repository at this point in the history
  • Loading branch information
Sevtinge committed Oct 31, 2023
1 parent dbf9d91 commit e844d32
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions app/src/main/java/com/sevtinge/cemiuiler/utils/BackupUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,23 @@ public static void handleCreateDocument(Activity activity, @Nullable Uri data) t
for (Map.Entry<String, ?> entry : PrefsUtils.mSharedPreferences.getAll().entrySet()) {
jsonObject.put(entry.getKey(), entry.getValue());
}
bufferedWriter.write(KS2Utils.encrypted(jsonObject.toString(), "\u0040\u0037\u0037\u0034\u0039\u0031"));
bufferedWriter.write(jsonObject.toString());
bufferedWriter.close();
}

public static void handleReadDocument(Activity activity, @Nullable Uri data) throws IOException, JSONException {
if (data == null) return;
SharedPreferences.Editor edit = PrefsUtils.mSharedPreferences.edit();
InputStream inputStream = activity.getContentResolver().openInputStream(data);
String documentContent = inputStream2String(inputStream);
String decryptedContent = KS2Utils.decrypted(documentContent, "\u0040\u0037\u0037\u0034\u0039\u0031");
JSONObject jsonObject = new JSONObject(decryptedContent);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder stringBuilder = new StringBuilder();
String line = bufferedReader.readLine();
while (line != null) {
stringBuilder.append(line);
line = bufferedReader.readLine();
}
String read = stringBuilder.toString();
JSONObject jsonObject = new JSONObject(read);
Iterator<String> keys = jsonObject.keys();
while (keys.hasNext()) {
String key = keys.next();
Expand All @@ -79,15 +85,4 @@ public static void handleReadDocument(Activity activity, @Nullable Uri data) thr
}
edit.apply();
}

private static String inputStream2String(InputStream inputStream) throws IOException {
StringBuilder stringBuilder = new StringBuilder();
String line;
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
while ((line = bufferedReader.readLine()) != null) {
stringBuilder.append(line);
}
bufferedReader.close();
return stringBuilder.toString();
}
}

0 comments on commit e844d32

Please sign in to comment.