Skip to content

Commit 1840b2b

Browse files
committed
improve naming of proof zip files to include formatted datetime and PGP key id
1 parent d72b417 commit 1840b2b

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

android-libproofmode/src/main/java/org/witness/proofmode/crypto/PgpUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.bouncycastle.bcpg.sig.KeyFlags;
1515
import org.bouncycastle.crypto.generators.RSAKeyPairGenerator;
1616
import org.bouncycastle.crypto.params.RSAKeyGenerationParameters;
17+
import org.bouncycastle.jcajce.provider.symmetric.util.PBE;
1718
import org.bouncycastle.openpgp.PGPCompressedDataGenerator;
1819
import org.bouncycastle.openpgp.PGPEncryptedData;
1920
import org.bouncycastle.openpgp.PGPEncryptedDataGenerator;
@@ -191,10 +192,10 @@ public String getPublicKey () throws IOException {
191192
ArmoredOutputStream armoredStreamPkr = new ArmoredOutputStream(baosPkr);
192193
pkr.encode(armoredStreamPkr);
193194
armoredStreamPkr.close();
195+
194196
return new String(baosPkr.toByteArray(), Charset.defaultCharset());
195197
}
196198

197-
198199
public final static String genPGPPrivKey (PGPKeyRingGenerator krgen) throws IOException {
199200
// String pgpPublicKey = PgpUtils.genPGPPublicKey(krgen);
200201
//DetachedSignatureProcessor.createSignature(pgpSecretKey, )

app/src/main/java/org/witness/proofmode/ShareProofActivity.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,16 @@ else if (Intent.ACTION_SEND.equals(action)) {
387387
else {
388388

389389
File fileFolder = MediaWatcher.getHashStorageDir(this,"zip");
390-
File fileZip = new File(fileFolder,"proofmode." + new Date().getTime() + ".zip");
391-
zip(shareUris,fileZip);
390+
391+
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss");
392+
String dateString = sdf.format(new Date());
393+
394+
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
395+
PgpUtils pu = PgpUtils.getInstance(this,prefs.getString("password",PgpUtils.DEFAULT_PASSWORD));
396+
String userId = pu.getPublicKeyFingerprint();
397+
398+
File fileZip = new File(fileFolder,"proofmode-" + userId + "-" + dateString + ".zip");
399+
zipProof(shareUris,fileZip);
392400

393401
Uri uriZip = FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID + ".provider",fileZip);
394402

@@ -866,7 +874,7 @@ private void askForPermission(String permission, Integer requestCode) {
866874

867875
private final static int BUFFER = 1024*8;
868876

869-
public void zip(ArrayList<Uri> uris, File fileZip) {
877+
public void zipProof(ArrayList<Uri> uris, File fileZip) {
870878
try {
871879
BufferedInputStream origin;
872880
FileOutputStream dest = new FileOutputStream(fileZip);

0 commit comments

Comments
 (0)