Jacob Collins Jacob Collins - 3 years ago 218
Java Question

SHA-512 hashing with Android

I was wondering if I can SHA-512 hash a string on Android Studio without a salt.

I've seen other questions, but they all involve the

, but I want something like this:

TestBox.text = sha512("Hello, world!");

will read

Answer Source

The other questions you saw use salt so just don't use salt like so:

MessageDigest md = MessageDigest.getInstance("SHA-512");
byte[] digest = md.digest("Hello, world!".getBytes());
StringBuilder sb = new StringBuilder();
for (int i = 0; i < digest.length; i++) {
    sb.append(Integer.toString((digest[i] & 0xff) + 0x100, 16).substring(1));

Based on this answer.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download