Edit ex2, not working yet

This commit is contained in:
Mariano Sciacco
2021-03-04 15:10:52 +01:00
parent bfa55c2c94
commit 6ddfaf5d97
4 changed files with 13 additions and 17 deletions

View File

@@ -12,7 +12,7 @@
<activity android:name=".HashfileActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="com.mobisec.intent.action.HASHFILE" />
<action android:name="com.mobiotsec.intent.action.HASHFILE" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

View File

@@ -25,8 +25,9 @@ public class HashfileActivity extends AppCompatActivity {
Intent intent = getIntent();
Log.d("MOBIOTSEC", "PROVA 1");
Log.d("MOBIOTSEC", intent.getAction());
//if(intent.getAction() == "com.mobiotsec.intent.action.HASHFILE") {
if(intent.getAction() == "com.mobiotsec.intent.action.HASHFILE") {
String filePath = intent.getData().getPath();
Log.d("MOBIOTSEC", filePath);
@@ -36,8 +37,6 @@ public class HashfileActivity extends AppCompatActivity {
hash = calcHash(filePath);
// return the hash in a "result" intent
Intent resultIntent = new Intent();
resultIntent.putExtra("hash", hash);
@@ -48,18 +47,15 @@ public class HashfileActivity extends AppCompatActivity {
e.printStackTrace();
}
//}
}
}
static public String calcHash(String filePath) throws IOException {
File file = new File(filePath);
if(file.exists()) {
Log.d("MOBIOTSEC", "PROVA 3");
return DigestUtils.sha256Hex(FileUtils.readFileToByteArray(file));
}
else
Log.d("MOBIOTSEC", "Errore");
Log.d("MOBIOTSEC", "PROVA 3");
byte[] bytes = FileUtils.readFileToByteArray(file);
Log.d("MOBIOTSEC", "PROVA 4");
return DigestUtils.sha256Hex(bytes);
return "prova";
}
}