mirror of
https://github.com/MaintainTeam/Hypatia.git
synced 2025-03-01 05:48:23 +03:00
Truncate all hashes to 16 characters to save memory
This commit is contained in:
parent
ed4d031d1f
commit
0720ccbec1
4 changed files with 9 additions and 8 deletions
|
@ -6,7 +6,7 @@ android {
|
||||||
applicationId "us.spotco.malwarescanner"
|
applicationId "us.spotco.malwarescanner"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 26
|
targetSdkVersion 26
|
||||||
versionCode 26
|
versionCode 27
|
||||||
versionName "2.2"
|
versionName "2.2"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
|
|
@ -103,7 +103,7 @@ class Database {
|
||||||
String line;
|
String line;
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
String[] lineS = line.split(":");
|
String[] lineS = line.split(":");
|
||||||
signaturesMD5.put(lineS[0], lineS[2]);
|
signaturesMD5.put(lineS[0].substring(0, Utils.MAX_HASH_LENGTH), lineS[2]);
|
||||||
}
|
}
|
||||||
reader.close();
|
reader.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -116,9 +116,9 @@ class Database {
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
String[] lineS = line.split(":");
|
String[] lineS = line.split(":");
|
||||||
if (lineS[0].length() == 32) {
|
if (lineS[0].length() == 32) {
|
||||||
signaturesSHA1.put(lineS[0], lineS[2]);
|
signaturesSHA1.put(lineS[0].substring(0, Utils.MAX_HASH_LENGTH), lineS[2]);
|
||||||
} else {
|
} else {
|
||||||
signaturesSHA256.put(lineS[0], lineS[2]);
|
signaturesSHA256.put(lineS[0].substring(0, Utils.MAX_HASH_LENGTH), lineS[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reader.close();
|
reader.close();
|
||||||
|
@ -128,7 +128,7 @@ class Database {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
signaturesMD5.put("44d88612fea8a8f36de82e1278abb02f", "Eicar-Test-Signature");
|
signaturesMD5.put("44d88612fea8a8f36de82e1278abb02f".substring(0, Utils.MAX_HASH_LENGTH), "Eicar-Test-Signature");
|
||||||
System.gc();
|
System.gc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,9 +147,9 @@ class MalwareScanner extends AsyncTask<Set<File>, Object, String> {
|
||||||
|
|
||||||
fis.close();
|
fis.close();
|
||||||
|
|
||||||
fileHashesMD5.put(String.format("%032x", new BigInteger(1, digestMD5.digest())), file);
|
fileHashesMD5.put(String.format("%032x", new BigInteger(1, digestMD5.digest())).substring(0, Utils.MAX_HASH_LENGTH), file);
|
||||||
fileHashesSHA1.put(String.format("%032x", new BigInteger(1, digestSHA1.digest())), file);
|
fileHashesSHA1.put(String.format("%032x", new BigInteger(1, digestSHA1.digest())).substring(0, Utils.MAX_HASH_LENGTH), file);
|
||||||
fileHashesSHA256.put(String.format("%064x", new BigInteger(1, digestSHA256.digest())), file);
|
fileHashesSHA256.put(String.format("%064x", new BigInteger(1, digestSHA256.digest())).substring(0, Utils.MAX_HASH_LENGTH), file);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ class Utils {
|
||||||
public final static int MAX_SCAN_SIZE = (1000 * 1000) * 80; //80MB
|
public final static int MAX_SCAN_SIZE = (1000 * 1000) * 80; //80MB
|
||||||
public final static int MAX_SCAN_SIZE_REALTIME = MAX_SCAN_SIZE / 2; //40MB
|
public final static int MAX_SCAN_SIZE_REALTIME = MAX_SCAN_SIZE / 2; //40MB
|
||||||
|
|
||||||
|
public final static int MAX_HASH_LENGTH = 16;
|
||||||
public static int FILES_SCANNED = 0;
|
public static int FILES_SCANNED = 0;
|
||||||
private static ThreadPoolExecutor threadPoolExecutor = null;
|
private static ThreadPoolExecutor threadPoolExecutor = null;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue