Skip to content

Commit 4e022a2

Browse files
committed
new interface
1 parent 4b0bd2d commit 4e022a2

28 files changed

+500
-75
lines changed

.idea/compiler.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 9 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/jarRepositories.xml

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AndroidFileVault.zip

1.75 MB
Binary file not shown.

app/build.gradle

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ android {
88
targetSdkVersion 28
99
versionCode 1
1010
versionName "1.0"
11-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
11+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1212
}
1313
buildTypes {
1414
release {
@@ -20,13 +20,15 @@ android {
2020

2121
dependencies {
2222
implementation fileTree(dir: 'libs', include: ['*.jar'])
23-
implementation 'com.android.support:appcompat-v7:28.0.0'
24-
implementation 'com.android.support.constraint:constraint-layout:2.0.4'
23+
implementation 'androidx.appcompat:appcompat:1.0.0'
24+
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
2525
testImplementation 'junit:junit:4.12'
26-
androidTestImplementation 'com.android.support.test:runner:1.0.2'
27-
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
28-
implementation 'com.android.support:support-v4:28.0.0'
29-
implementation 'com.android.support:design:28.0.0'
26+
androidTestImplementation 'androidx.test:runner:1.1.0'
27+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
28+
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
29+
implementation 'com.google.android.material:material:1.0.0'
3030
implementation 'net.zetetic:android-database-sqlcipher:4.4.2@aar'
3131
implementation "androidx.sqlite:sqlite:2.0.1"
32+
33+
implementation 'commons-codec:commons-codec:1.15'
3234
}

app/src/androidTest/java/com/katcom/androidFileVault/ExampleInstrumentedTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.katcom.androidFileVault;
22

33
import android.content.Context;
4-
import android.support.test.InstrumentationRegistry;
5-
import android.support.test.runner.AndroidJUnit4;
4+
import androidx.test.InstrumentationRegistry;
5+
import androidx.test.runner.AndroidJUnit4;
66

77
import org.junit.Test;
88
import org.junit.runner.RunWith;
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package com.katcom.androidFileVault;
2+
3+
import android.content.Intent;
4+
import android.net.Uri;
5+
6+
import androidx.annotation.Nullable;
7+
8+
import javax.crypto.CipherInputStream;
9+
import javax.crypto.CipherOutputStream;
10+
import javax.crypto.SecretKey;
11+
import java.io.InputStream;
12+
import java.net.URI;
13+
14+
public abstract class Crypto {
15+
final String keyName = "myKey"; // AKA alias;
16+
// because using Android keystore, we don't have access to the key itself, so we need an alias
17+
18+
/**
19+
* This method returns an InputStream pointed to the files that user copies to vault
20+
* @return
21+
*/
22+
InputStream importFile(InputStream in){
23+
CipherOutputStream out = encrypt()
24+
while(in.read() != -1){
25+
int data= in.read();
26+
out.write(data);
27+
28+
};
29+
}
30+
31+
/**
32+
*
33+
* @param in
34+
* @return
35+
*/
36+
CipherOutputStream getEncryptedFileOutStream(String targetPath, String key, byte[] iv){
37+
38+
}
39+
40+
41+
42+
43+
/**
44+
* When user clicks import button, call this method
45+
*/
46+
void importAndEncrypt(Uri uri){
47+
// get the selected file and encrypt it
48+
InputStream in = getInputStreamFromUri(uri);
49+
String filename = getFilenameFromUri(uri);
50+
String targetPath = "/Vault/" + filename;
51+
52+
// Above we get the data in the file,
53+
// Encrypt the data here
54+
byte[] iv = filename.getBytes();
55+
CipherOutputStream out = getEncryptedFileOutStream(targetPath, key,iv);
56+
57+
// write encrypted data
58+
writeData(in,out);
59+
60+
}
61+
62+
void generateSecretKey(){
63+
// Use the alias to generate a key
64+
// Use keystore;
65+
}
66+
67+
68+
69+
70+
@Override
71+
protected void onActivityResult(final int requestCode, final int resultCode, @Nullable final Intent data) {
72+
73+
int count = data.getClipData().getItemCount();
74+
75+
for (int i = 0; i < count; i++) {
76+
Uri SelectedFile = data.getClipData().getItemAt(i).getUri();
77+
importFile(uri);
78+
}
79+
80+
}
81+
82+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.katcom.androidFileVault;
2+
3+
import android.net.Uri;
4+
5+
import javax.crypto.CipherOutputStream;
6+
7+
public interface Crypto {
8+
9+
CipherOutputStream getEncryptedFileOutStream(String targetPath, String key, byte[] iv);
10+
11+
/**
12+
* This method gets the data in the file and encrypt it
13+
*/
14+
void importAndEncrypt(Uri uri);
15+
/*{
16+
// get the selected file and encrypt it
17+
InputStream in = getInputStreamFromUri(uri);
18+
String filename = getFilenameFromUri(uri);
19+
String targetPath = "/Vault/" + filename;
20+
21+
// Above we get the data in the file,
22+
// Encrypt the data here
23+
byte[] iv = filename.getBytes();
24+
CipherOutputStream out = getEncryptedFileOutStream(targetPath, key,iv);
25+
26+
// write encrypted data
27+
writeData(in,out);
28+
29+
}*/
30+
31+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.katcom.androidFileVault.DataBase;
2+
3+
import android.content.Context;
4+
import android.database.sqlite.SQLiteDatabase;
5+
import android.database.sqlite.SQLiteOpenHelper;
6+
7+
import androidx.annotation.Nullable;
8+
9+
public class DBHelper extends SQLiteOpenHelper {
10+
private static final int VERSION =1;
11+
private static final String DATABASE_NAME = "fileBase.db";
12+
public DBHelper(@Nullable Context context) {
13+
super(context,DATABASE_NAME,null,VERSION);
14+
15+
}
16+
17+
@Override
18+
public void onCreate(SQLiteDatabase db) {
19+
20+
}
21+
22+
@Override
23+
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
24+
25+
}
26+
}

0 commit comments

Comments
 (0)