Skip to content

Commit 8a034db

Browse files
committed
oli
1 parent ff834a0 commit 8a034db

File tree

4 files changed

+98
-14
lines changed

4 files changed

+98
-14
lines changed

src/main/java/edu/uniandes/tsdl/mutapk/hashfunction/sha3/ApkHashOrder.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package edu.uniandes.tsdl.mutapk.hashfunction.sha3;
22

33
import java.util.HashMap;
4+
import java.util.HashSet;
45
import java.util.Map;
6+
import java.util.Set;
57

68
/**
79
* University of Los Andes
@@ -41,15 +43,16 @@ public synchronized ApkHashSeparator setApkHashSeparator(ApkHashSeparator nuevoA
4143
if(isDuplicate) {
4244
ApkHashSeparator duplicate = apkHashesSeparator.get(nuevoApkHashSeparator);
4345
if(duplicate != null && nuevoApkHashSeparator.equals(duplicate)) {
44-
System.out.println("ES IGUAL: " + nuevoApkHashSeparator.equals(duplicate));
45-
System.out.println("ES IGUAL Nuevo: " + nuevoApkHashSeparator.getMutanteId());
46-
System.out.println("ES IGUAL Nuevo Manifest: " + nuevoApkHashSeparator.getMutanteId() + " " + nuevoApkHashSeparator.getHashManifest());
47-
System.out.println("ES IGUAL Nuevo Smali: " + nuevoApkHashSeparator.getMutanteId() + " " + nuevoApkHashSeparator.getHashSmali());
48-
System.out.println("ES IGUAL Nuevo Resource: " + nuevoApkHashSeparator.getMutanteId() + " " + nuevoApkHashSeparator.getHashResource());
49-
System.out.println("ES IGUAL Nuevo: " + nuevoApkHashSeparator.getMutanteId() + " Viejo " + duplicate.getMutanteId());
50-
System.out.println("ES IGUAL Nuevo Manifest: " + nuevoApkHashSeparator.getMutanteId() + " Viejo " + duplicate.getMutanteId() + " " + nuevoApkHashSeparator.getHashManifest());
51-
System.out.println("ES IGUAL Nuevo Smali: " + nuevoApkHashSeparator.getMutanteId() + " Viejo " + duplicate.getMutanteId() + " " + nuevoApkHashSeparator.getHashSmali());
52-
System.out.println("ES IGUAL Nuevo Resource: " + nuevoApkHashSeparator.getMutanteId() + " Viejo " + duplicate.getMutanteId() + " " + nuevoApkHashSeparator.getHashResource());
46+
// System.out.println("ES IGUAL: " + nuevoApkHashSeparator.equals(duplicate));
47+
// System.out.println("ES IGUAL Nuevo: " + nuevoApkHashSeparator.getMutanteId());
48+
// System.out.println("ES IGUAL Nuevo Manifest: " + nuevoApkHashSeparator.getMutanteId() + " " + nuevoApkHashSeparator.getHashManifest());
49+
// System.out.println("ES IGUAL Nuevo Smali: " + nuevoApkHashSeparator.getMutanteId() + " " + nuevoApkHashSeparator.getHashSmali());
50+
// System.out.println("ES IGUAL Nuevo Resource: " + nuevoApkHashSeparator.getMutanteId() + " " + nuevoApkHashSeparator.getHashResource());
51+
// System.out.println("ES IGUAL Nuevo: " + nuevoApkHashSeparator.getMutanteId() + " Viejo " + duplicate.getMutanteId());
52+
// System.out.println("ES IGUAL Nuevo Manifest: " + nuevoApkHashSeparator.getMutanteId() + " Viejo " + duplicate.getMutanteId() + " " + nuevoApkHashSeparator.getHashManifest());
53+
// System.out.println("ES IGUAL Nuevo Smali: " + nuevoApkHashSeparator.getMutanteId() + " Viejo " + duplicate.getMutanteId() + " " + nuevoApkHashSeparator.getHashSmali());
54+
// System.out.println("ES IGUAL Nuevo Resource: " + nuevoApkHashSeparator.getMutanteId() + " Viejo " + duplicate.getMutanteId() + " " + nuevoApkHashSeparator.getHashResource());
55+
System.out.println("Nuevo HashCode: " + nuevoApkHashSeparator.hashCode() + "Viejo HashCode: " + duplicate.hashCode());
5356
return duplicate;
5457
}
5558
}

src/main/java/edu/uniandes/tsdl/mutapk/hashfunction/sha3/ApkHashSeparator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public int hashCode() {
8686

8787
@Override
8888
public String toString() {
89-
return hashManifest + "|" + hashResource + "|" + hashSmali;
89+
return hashManifest + "||" + hashResource + "||" + hashSmali;
9090
}
9191

9292
}

src/test/java/edu/uniandes/tsdl/mutapk/hashfunction/sha3/ApkHashSeparatorTest.java

Lines changed: 39 additions & 4 deletions
Large diffs are not rendered by default.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package edu.uniandes.tsdl.mutapk.hashfunction.sha3;
2+
3+
import static org.junit.Assert.*;
4+
5+
import java.io.File;
6+
import java.io.FileNotFoundException;
7+
import java.io.IOException;
8+
9+
import org.junit.Test;
10+
11+
public class Sha3Test {
12+
13+
14+
String apkAbsolutePath = "C:\\Users\\PERSONAL\\git\\MutAPK\\test\\temp";
15+
File manifest = new File(apkAbsolutePath + File.separator + "AndroidManifest.xml");
16+
File smali = new File(apkAbsolutePath + File.separator + "smali");
17+
File resource = new File(apkAbsolutePath + File.separator + "res");
18+
19+
@Test
20+
public void equalHashTest() throws FileNotFoundException, IOException {
21+
String hashManifest = Sha3.sha512FileSeparte(manifest);
22+
String hashSmali = Sha3.sha512FileSeparte(smali);
23+
String hashResource = Sha3.sha512FileSeparte(resource);
24+
25+
String hashManifestCompare = "";
26+
String hashSmaliCompare = "";
27+
String hashResourceCompare = "";
28+
29+
for (int i = 0; i < 10; i++) {
30+
hashManifestCompare = Sha3.sha512FileSeparte(manifest);
31+
hashSmaliCompare = Sha3.sha512FileSeparte(smali);
32+
hashResourceCompare = Sha3.sha512FileSeparte(resource);
33+
34+
if(!hashManifest.equals(hashManifestCompare)) {
35+
fail("They should be always equals");
36+
}
37+
if(!hashSmali.equals(hashSmaliCompare)) {
38+
fail("They should be always equals");
39+
}
40+
if(!hashResource.equals(hashResourceCompare)) {
41+
fail("They should be always equals");
42+
}
43+
}
44+
}
45+
46+
}

0 commit comments

Comments
 (0)