Skip to content

Commit

Permalink
Merge pull request #7 from appknox/hashbytes
Browse files Browse the repository at this point in the history
fix MD5 hash representation in Snackbar
  • Loading branch information
cosmosgenius authored May 12, 2022
2 parents 18cbb32 + 4012269 commit 35bc617
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/src/main/java/com/appknox/mfva/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ public void onClick(View v) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] hash = md.digest(quote.getBytes());
Snackbar.make(v, "MD5:" + hash.toString() + ": " + quote, Snackbar.LENGTH_SHORT).show();
StringBuilder hashStr = new StringBuilder(hash.length * 2);
for(byte b: hash)
hashStr.append(String.format("%02x", b));
Snackbar.make(v, "MD5: [" + hashStr + "] : " + quote, Snackbar.LENGTH_SHORT).show();
} catch (NoSuchAlgorithmException e) {
Snackbar.make(v, e.toString(), Snackbar.LENGTH_SHORT).show();
}
Expand Down

0 comments on commit 35bc617

Please # to comment.