Edit ex2, not working yet
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user