Created
October 21, 2014 05:05
-
-
Save prurigro/1e6bf772e0e712149745 to your computer and use it in GitHub Desktop.
(pixel-dungeon-gdx) Patch to disable encrypted save files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/PD-classes/src/com/watabou/utils/Bundle.java b/PD-classes/src/com/watabou/utils/Bundle.java | |
| index e266acc..39a47ec 100644 | |
| --- a/PD-classes/src/com/watabou/utils/Bundle.java | |
| +++ b/PD-classes/src/com/watabou/utils/Bundle.java | |
| @@ -264,27 +264,12 @@ public class Bundle { | |
| } | |
| } | |
| - | |
| - private static final char XOR_KEY = 0x1F; | |
| - | |
| + | |
| public static Bundle read( InputStream stream ) { | |
| try { | |
| BufferedReader reader = new BufferedReader( new InputStreamReader( stream ) ); | |
| - | |
| - StringBuilder builder = new StringBuilder(); | |
| - | |
| - char[] buffer = new char[0x2000]; | |
| - int count = reader.read( buffer ); | |
| - while (count > 0) { | |
| - for (int i=0; i < count; i++) { | |
| - buffer[i] ^= XOR_KEY; | |
| - } | |
| - builder.append( buffer, 0, count ); | |
| - count = reader.read( buffer ); | |
| - } | |
| - | |
| - JSONObject json = (JSONObject)new JSONTokener( builder.toString() ).nextValue(); | |
| + JSONObject json = (JSONObject)new JSONTokener( reader.readLine() ).nextValue(); | |
| reader.close(); | |
| return new Bundle( json ); | |
| @@ -295,13 +280,8 @@ public class Bundle { | |
| public static boolean write( Bundle bundle, OutputStream stream ) { | |
| try { | |
| - BufferedWriter writer = new BufferedWriter( new OutputStreamWriter( stream ) ); | |
| - | |
| - char[] chars = bundle.data.toString().toCharArray(); | |
| - for (int i=0; i < chars.length; i++) { | |
| - chars[i] ^= XOR_KEY; | |
| - } | |
| - writer.write( chars ); | |
| + BufferedWriter writer = new BufferedWriter( new OutputStreamWriter( stream ) ); | |
| + writer.write( bundle.data.toString() ); | |
| writer.close(); | |
| return true; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment