-
-
Save freekman/0c3643e3a8d5caf1f8e9558ae916840b to your computer and use it in GitHub Desktop.
simple hashing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static String sha1(String input) { | |
MessageDigest mDigest = null; | |
try { | |
mDigest = MessageDigest.getInstance("SHA1"); | |
} catch (NoSuchAlgorithmException e) { | |
return ""; | |
} | |
byte[] result = mDigest.digest(input.getBytes()); | |
StringBuffer sb = new StringBuffer(); | |
for (int i = 0; i < result.length; i++) { | |
sb.append(Integer.toString((result[i] & 0xff) + 0x100, 16).substring(1)); | |
} | |
return sb.toString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment