[android] #3960 - Return hex strings of SHA1 digests

This commit is contained in:
Brad Leege
2016-02-15 17:02:41 -06:00
parent 47dc38bf4a
commit a3f8710574

View File

@@ -243,7 +243,16 @@ public class MapboxEventManager {
messageDigest.reset();
messageDigest.update(string.getBytes("UTF-8"));
byte[] bytes = messageDigest.digest();
return new String(bytes);
// Get the Hex version of the digest
StringBuilder sb = new StringBuilder();
for (byte b : bytes) {
sb.append( String.format("%02X", b) );
}
String hex = sb.toString();
Log.d(TAG, "original = " + string + "; hex = " + hex);
return hex;
}
} catch (Exception e) {
Log.w(TAG, "Error encoding string, will return in original form." + e);