List of utility methods to do SHA256 Hash Create
String | sha256(String input) Calculated the SHA-256 hash of the given input string. try { MessageDigest md = MessageDigest.getInstance("SHA-256"); byte[] hashedBytes = md.digest(input.getBytes()); StringBuilder output = new StringBuilder(hashedBytes.length); for (int i = 0; i < hashedBytes.length; i++) { String hex = Integer.toHexString(0xFF & hashedBytes[i]); if (hex.length() == 1) hex = "0" + hex; ... |
String | sha256(String string) Generate a SHA256 checksum of a string. MessageDigest digest = null; String hash = ""; try { digest = MessageDigest.getInstance("SHA-256"); digest.update(string.getBytes()); byte[] bytes = digest.digest(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < bytes.length; i++) { ... |
byte[] | sha256(byte[] data) sha return sha256(data, 0, data.length);
|
byte[] | sha256(byte[] data, int offset, int length) sha try { MessageDigest digest; digest = MessageDigest.getInstance(SHA256); digest.update(data, offset, length); return digest.digest(); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); |
byte[] | sha256(byte[] data1, byte[] data2) sha try { MessageDigest digest; digest = MessageDigest.getInstance(SHA256); digest.update(data1, 0, data1.length); digest.update(data2, 0, data2.length); return digest.digest(); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); ... |
String | sha256(final String aString) sha String result = null; if (TextUtils.isEmpty(aString)) return result; MessageDigest md; StringBuffer hexString = new StringBuffer(); try { md = MessageDigest.getInstance("SHA-256"); md.reset(); ... |
byte[] | sha256Byte(String in) Returns a byte array representation of the hash of a string input using the SHA256 hashing algorithm. return digestByte("SHA256", in.getBytes()); |
byte[] | sha256Byte(byte[] in) Returns a byte array representation of the hash of a byte array input using the SHA256 hashing algorithm. return digestByte("SHA256", in); |
byte[] | doubleSha256(byte[] data) double Sha return doubleSha256(data, 0, data.length);
|
byte[] | doubleSha256(byte[] data, int offset, int length) double Sha try { MessageDigest digest; digest = MessageDigest.getInstance(SHA256); digest.update(data, offset, length); return digest.digest(digest.digest()); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); |