mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Successfully able to output the uneycrypted version of the database, and calculate SHA-256 checksum.
Needed to leave Meta-Stream entries in the PwManager, and ensure that nulls are included in string output.
This commit is contained in:
@@ -60,7 +60,7 @@ public class PwEntryOutput {
|
||||
//byte[] title = mPE.title.getBytes("UTF-8");
|
||||
mOS.write(TITLE_FIELD_TYPE);
|
||||
Types.writeCString(mPE.title, mOS);
|
||||
|
||||
|
||||
// URL
|
||||
mOS.write(URL_FIELD_TYPE);
|
||||
Types.writeCString(mPE.url, mOS);
|
||||
@@ -75,11 +75,11 @@ public class PwEntryOutput {
|
||||
mOS.write(Types.writeInt(password.length+1));
|
||||
mOS.write(password);
|
||||
mOS.write(0);
|
||||
|
||||
|
||||
// Additional
|
||||
mOS.write(ADDITIONAL_FIELD_TYPE);
|
||||
Types.writeCString(mPE.additional, mOS);
|
||||
|
||||
|
||||
// Create date
|
||||
mOS.write(CREATE_FIELD_TYPE);
|
||||
mOS.write(DATE_FIELD_SIZE);
|
||||
|
||||
@@ -40,6 +40,7 @@ public class PwGroupOutput {
|
||||
|
||||
//NOTE: Need be to careful about using ints. The actual type written to file is a unsigned int
|
||||
public void output() throws IOException {
|
||||
|
||||
// Group ID
|
||||
mOS.write(GROUPID_FIELD_TYPE);
|
||||
mOS.write(GROUPID_FIELD_SIZE);
|
||||
|
||||
@@ -243,6 +243,7 @@ public class ImporterV3 {
|
||||
}
|
||||
|
||||
// Keep the Meta-Info entry separate
|
||||
/*
|
||||
for( int i=0; i<newManager.entries.size(); i++) {
|
||||
PwEntry ent = (PwEntry)newManager.entries.elementAt(i);
|
||||
if( ent.title.equals( "Meta-Info" )
|
||||
@@ -252,6 +253,7 @@ public class ImporterV3 {
|
||||
newManager.entries.removeElementAt(i);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
return newManager;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import junit.framework.TestCase;
|
||||
import org.phoneid.keepassj2me.PwEntry;
|
||||
import org.phoneid.keepassj2me.PwGroup;
|
||||
import org.phoneid.keepassj2me.PwManager;
|
||||
import org.phoneid.keepassj2me.Types;
|
||||
|
||||
import com.android.keepass.keepasslib.PwEntryOutput;
|
||||
import com.android.keepass.keepasslib.PwGroupOutput;
|
||||
@@ -61,19 +62,16 @@ public class PwGroupOutputTest extends TestCase {
|
||||
|
||||
// Entries
|
||||
for (int i = 0; i < mPM.entries.size(); i++ ) {
|
||||
boolean debug;
|
||||
PwEntry pe = mPM.entries.get(i);
|
||||
PwEntryOutput peo = new PwEntryOutput(pe, bos);
|
||||
|
||||
debug = (i == 1);
|
||||
peo.output();
|
||||
}
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(mPM.groups.get(1).tCreation);
|
||||
byte[] buf = bos.toByteArray();
|
||||
for (int i = 0; i < buf.length; i++) {
|
||||
assertEquals("Buf31: " + mPM.postHeader[31] + " Buf32: " + mPM.postHeader[32] + "Buf33: " + mPM.postHeader[33] + " Year: " + cal.get(Calendar.YEAR) + " Month: " + cal.get(Calendar.MONTH) + " Difference at byte " + i, mPM.postHeader[i], buf[i]);
|
||||
}
|
||||
|
||||
//assertArrayEquals(mPM.postHeader, bos.toByteArray());
|
||||
assertArrayEquals(mPM.postHeader, bos.toByteArray());
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user