List of utility methods to do Hash Code Calculate
int | combineHashesUnsorted(final int a, final int b) Combine two hash codes. return (a + b);
|
byte[] | generateHash(byte[] data) generate Hash MessageDigest sha = null; try { sha = MessageDigest.getInstance("SHA-256"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); sha.update(data); return sha.digest(); ... |
byte[] | generateHash(char[] password, byte[] salt) generate Hash PBEKeySpec spec = new PBEKeySpec(password, salt, HASH_ITERATIONS, KEY_LENGTH); Arrays.fill(password, Character.MIN_VALUE); try { SecretKeyFactory skf = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); return skf.generateSecret(spec).getEncoded(); } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { throw new AssertionError("Error while hashing a password: " + e.getMessage(), e); } finally { ... |
byte[] | generateHash(File file) generate Hash InputStream in = new BufferedInputStream(new FileInputStream(file)); byte hash[] = null; try { hash = generateHash(in); } finally { in.close(); return hash; ... |
String | generateHash(final String data) generate Hash String result = null; StringBuffer toHash = new StringBuffer(); toHash.append(data); toHash.append(SECRET_SALT); try { byte[] bytesOfMessage = toHash.toString().getBytes("UTF-8"); MessageDigest md = MessageDigest.getInstance("MD5"); byte[] thedigest = md.digest(bytesOfMessage); ... |
String | generateHash(final String input) Generates a hashed string in MD5-format for the given string. MessageDigest messageDigest; try { messageDigest = MessageDigest.getInstance("MD5"); messageDigest.update(input.getBytes(), 0, input.length()); return new BigInteger(1, messageDigest.digest()).toString(16); } catch (final NoSuchAlgorithmException e) { e.printStackTrace(); throw new RuntimeException("No such hash algorithm!"); ... |
String | generateHash(final String msg, final String hashAlgorithm) generate Hash if (!hashAlgorithm.equals("plain")) { StringBuffer hexString = new StringBuffer(); try { MessageDigest messageDigest = MessageDigest.getInstance(hashAlgorithm); messageDigest.update(msg.getBytes()); byte[] digest = messageDigest.digest(); for (byte aDigest : digest) { String val = Integer.toHexString(0xFF & aDigest); ... |
byte[] | generateHash(String algo, byte[]... bytes) generate Hash MessageDigest digest = MessageDigest.getInstance(algo); for (int i = 0; i < bytes.length; ++i) { digest.update(bytes[i]); return digest.digest(); |
String | generateHash(String input) Pre: input!=null Post: Genera un Hash para el texto pasado. String md5 = null; if (null == input) return null; try { MessageDigest digest = MessageDigest.getInstance("MD5"); digest.update(input.getBytes(), 0, input.length()); md5 = new BigInteger(1, digest.digest()).toString(16); } catch (NoSuchAlgorithmException e) { ... |
String | generateHash(String input, String salt) generate Hash MessageDigest md = MessageDigest.getInstance("MD5"); String hash = ""; if (salt == null) { salt = ""; input += salt; byte[] data = input.getBytes("US-ASCII"); md.update(data); ... |