Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Commit

Permalink
Attempt to fix allowed accounts
Browse files Browse the repository at this point in the history
Refs #1664
  • Loading branch information
M66B committed May 17, 2014
1 parent 79b4d8e commit 616c204
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/biz/bokhorst/xprivacy/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,14 @@ private static boolean verifyData(byte[] data, byte[] signature, PublicKey publi
return verifier.verify(signature);
}

private static String getSalt() {
return (Build.SERIAL == null ? "" : Build.SERIAL);
}

public static String sha1(String text) throws NoSuchAlgorithmException, UnsupportedEncodingException {
// SHA1
int userId = Util.getUserId(Process.myUid());
String salt = PrivacyManager.getSetting(userId, PrivacyManager.cSettingSalt, Build.SERIAL, true);
String salt = PrivacyManager.getSetting(userId, PrivacyManager.cSettingSalt, getSalt(), true);
MessageDigest digest = MessageDigest.getInstance("SHA-1");
byte[] bytes = (text + salt).getBytes("UTF-8");
digest.update(bytes, 0, bytes.length);
Expand All @@ -448,7 +452,7 @@ public static String sha1(String text) throws NoSuchAlgorithmException, Unsuppor
public static String md5(String text) throws NoSuchAlgorithmException, UnsupportedEncodingException {
// MD5
int userId = Util.getUserId(Process.myUid());
String salt = PrivacyManager.getSetting(userId, PrivacyManager.cSettingSalt, Build.SERIAL, true);
String salt = PrivacyManager.getSetting(userId, PrivacyManager.cSettingSalt, getSalt(), true);
byte[] bytes = MessageDigest.getInstance("MD5").digest((text + salt).getBytes("UTF-8"));
StringBuilder sb = new StringBuilder();
for (byte b : bytes)
Expand Down

0 comments on commit 616c204

Please sign in to comment.