Using LZMA for bin backup decompression to try to solve the compatibility issue
This commit is contained in:
parent
09974a66f6
commit
577af21b67
4 changed files with 34 additions and 12 deletions
|
@ -4,6 +4,10 @@ import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import de.bitsharesmunich.graphenej.crypto.SecureRandomStrengthener;
|
import de.bitsharesmunich.graphenej.crypto.SecureRandomStrengthener;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
|
@ -42,13 +46,28 @@ public abstract class FileBin {
|
||||||
MessageDigest md1 = MessageDigest.getInstance("SHA-512");
|
MessageDigest md1 = MessageDigest.getInstance("SHA-512");
|
||||||
finalKey = md1.digest(finalKey);
|
finalKey = md1.digest(finalKey);
|
||||||
byte[] rawData = Util.decryptAES(rawDataEncripted, Util.byteToString(finalKey).getBytes());
|
byte[] rawData = Util.decryptAES(rawDataEncripted, Util.byteToString(finalKey).getBytes());
|
||||||
|
|
||||||
|
try {
|
||||||
|
FileOutputStream out = new FileOutputStream("/Users/nelson/Development/Java/Fullerene/src/main/java/de/bitsharesmunich/graphenej/decrypted.bin");
|
||||||
|
out.write(rawData);
|
||||||
|
out.close();
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
System.out.println("FileNotFoundException. Msg: "+e.getMessage());
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("IOException. Msg: "+e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
byte[] checksum = new byte[4];
|
byte[] checksum = new byte[4];
|
||||||
System.arraycopy(rawData, 0, checksum, 0, 4);
|
System.arraycopy(rawData, 0, checksum, 0, 4);
|
||||||
byte[] compressedData = new byte[rawData.length - 4];
|
byte[] compressedData = new byte[rawData.length - 4];
|
||||||
System.arraycopy(rawData, 4, compressedData, 0, compressedData.length);
|
System.arraycopy(rawData, 4, compressedData, 0, compressedData.length);
|
||||||
|
|
||||||
byte[] wallet_object_bytes = Util.decompress(compressedData, Util.XZ);
|
System.out.println("raw: "+Util.bytesToHex(rawData));
|
||||||
|
System.out.println("checksum: "+Util.bytesToHex(checksum));
|
||||||
|
System.out.println("compressed: "+Util.bytesToHex(compressedData));
|
||||||
|
|
||||||
|
byte[] wallet_object_bytes = Util.decompress(rawData, Util.LZMA);
|
||||||
String wallet_string = new String(wallet_object_bytes, "UTF-8");
|
String wallet_string = new String(wallet_object_bytes, "UTF-8");
|
||||||
JsonObject wallet = new JsonParser().parse(wallet_string).getAsJsonObject();
|
JsonObject wallet = new JsonParser().parse(wallet_string).getAsJsonObject();
|
||||||
if (wallet.get("wallet").isJsonArray()) {
|
if (wallet.get("wallet").isJsonArray()) {
|
||||||
|
|
|
@ -17,6 +17,8 @@ public class Main {
|
||||||
|
|
||||||
public static final String WIF = "5KMzB2GqGhnh7ufhgddmz1eKPHS72uTLeL9hHjSvPb1UywWknF5";
|
public static final String WIF = "5KMzB2GqGhnh7ufhgddmz1eKPHS72uTLeL9hHjSvPb1UywWknF5";
|
||||||
|
|
||||||
|
public static final String BILTHON_83_PASSWORD = System.getenv("BILTHON_83_PASSWORD");
|
||||||
|
|
||||||
// Static block information used for transaction serialization tests
|
// Static block information used for transaction serialization tests
|
||||||
public static int REF_BLOCK_NUM = 56204;
|
public static int REF_BLOCK_NUM = 56204;
|
||||||
public static int REF_BLOCK_PREFIX = 1614747814;
|
public static int REF_BLOCK_PREFIX = 1614747814;
|
||||||
|
@ -59,8 +61,8 @@ public class Main {
|
||||||
// test.testAccountUpdateSerialization();
|
// test.testAccountUpdateSerialization();
|
||||||
// test.testAccountUpdateOperationBroadcast();
|
// test.testAccountUpdateOperationBroadcast();
|
||||||
// test.testCreateBinFile();
|
// test.testCreateBinFile();
|
||||||
// test.testImportBinFile();
|
test.testImportBinFile();
|
||||||
// test.testLookupAccounts();
|
// test.testLookupAccounts();
|
||||||
// test.testLookupAccounts();
|
// test.testLookupAccounts();
|
||||||
// test.testDecodeMemo();
|
// test.testDecodeMemo();
|
||||||
// test.testGetRelativeAccountHistory();
|
// test.testGetRelativeAccountHistory();
|
||||||
|
@ -74,6 +76,6 @@ public class Main {
|
||||||
// test.testGetMarketHistory();
|
// test.testGetMarketHistory();
|
||||||
// test.testGetAccountBalances();
|
// test.testGetAccountBalances();
|
||||||
// test.testGetAssetHoldersCount();
|
// test.testGetAssetHoldersCount();
|
||||||
test.testSubscription(null);
|
// test.testSubscription(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -632,11 +632,11 @@ public class Test {
|
||||||
public void testImportBinFile() {
|
public void testImportBinFile() {
|
||||||
try {
|
try {
|
||||||
String current = new File(".").getCanonicalPath();
|
String current = new File(".").getCanonicalPath();
|
||||||
File file = new File(current + "/src/main/java/de/bitsharesmunich/graphenej/bts_bilthon_20161218.bin");
|
File file = new File(current + "/src/main/java/de/bitsharesmunich/graphenej/bts_bilthon-83_20170131.bin");
|
||||||
Path path = Paths.get(file.getAbsolutePath());
|
Path path = Paths.get(file.getAbsolutePath());
|
||||||
byte[] data = Files.readAllBytes(path);
|
byte[] data = Files.readAllBytes(path);
|
||||||
|
|
||||||
System.out.println(FileBin.getBrainkeyFromByte(data, "123456"));
|
String brainKey = FileBin.getBrainkeyFromByte(data, Main.BILTHON_83_PASSWORD);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("IOException while trying to open bin file. Msg: "+e.getMessage());
|
System.out.println("IOException while trying to open bin file. Msg: "+e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,10 +140,11 @@ public class Util {
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Logger.getLogger(Util.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(Util.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
// try {
|
||||||
in.close();
|
// in.close();
|
||||||
} catch (IOException ex) {
|
// } catch (IOException ex) {
|
||||||
Logger.getLogger(Util.class.getName()).log(Level.SEVERE, null, ex); }
|
// Logger.getLogger(Util.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue