List of usage examples for org.apache.commons.codec.digest MessageDigestAlgorithms SHA_256
String SHA_256
To view the source code for org.apache.commons.codec.digest MessageDigestAlgorithms SHA_256.
Click Source Link
From source file:it.infn.mw.iam.util.ssh.RSAPublicKeyUtils.java
private static String buildSHA256Fingerprint(String key) throws InvalidSshKeyException { String fingerprint = null;//from w ww. java 2 s . com try { byte[] decodedKey = Base64.getDecoder().decode(key); byte[] digest = MessageDigest.getInstance(MessageDigestAlgorithms.SHA_256).digest(decodedKey); fingerprint = Base64.getEncoder().encodeToString(digest); } catch (Exception e) { throw new InvalidSshKeyException("Error during fingerprint generation: RSA key is not base64 encoded", e); } return fingerprint; }
From source file:com.redhat.victims.VictimsResultCache.java
/** * The hashing function used by the Cache. * //from www. j av a2 s . co m * @param key * @return * @throws VictimsException */ protected String hash(String key) throws VictimsException { try { MessageDigest mda = MessageDigest.getInstance(MessageDigestAlgorithms.SHA_256); return Hex.encodeHexString(mda.digest(key.getBytes())); } catch (NoSuchAlgorithmException e) { throw new VictimsException(String.format("Could not hash key: %s", key), e); } }
From source file:com.aoppp.gatewaysdk.internal.hw.DigestUtils2.java
/** * Returns an SHA-256 digest.//from www . j av a 2s . c o m * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @return An SHA-256 digest instance. * @throws IllegalArgumentException * when a {@link NoSuchAlgorithmException} is caught, which should never happen because SHA-256 is a * built-in algorithm * @see MessageDigestAlgorithms#SHA_256 */ public static MessageDigest getSha256Digest() { return getDigest(MessageDigestAlgorithms.SHA_256); }