List of usage examples for com.google.common.hash Hashing sha256
public static HashFunction sha256()
From source file:org.apache.james.mailbox.model.BlobId.java
public static BlobId fromBytes(byte[] bytes) { Preconditions.checkNotNull(bytes);//from w w w .jav a2 s.co m return new BlobId(Hashing.sha256().hashBytes(bytes).toString()); }
From source file:org.cloudme.armada.util.TokenUtils.java
/** * Creates a hash of the given value. The hashing algorithm is currently SHA-256. * // w w w .j av a 2 s.c o m * @param value * The original value. * @return The hashed value. */ public static String hash(String value) { return Hashing.sha256().hashBytes(value.getBytes()).toString(); }
From source file:io.servicecomb.demo.signature.SignatureUtils.java
public static String genSignature(HttpServletRequestEx requestEx) { Hasher hasher = Hashing.sha256().newHasher(); hasher.putString(requestEx.getRequestURI(), StandardCharsets.UTF_8); for (String paramName : paramNames) { String paramValue = requestEx.getHeader(paramName); if (paramValue != null) { hasher.putString(paramName, StandardCharsets.UTF_8); hasher.putString(paramValue, StandardCharsets.UTF_8); System.out.printf("%s %s\n", paramName, paramValue); }//from www .j a va2 s . co m } byte[] bytes = requestEx.getBodyBytes(); if (bytes != null) { hasher.putBytes(bytes, 0, requestEx.getBodyBytesLength()); } return hasher.hash().toString(); }
From source file:com.Yakreem15.ejb.UserBean.java
public void signUp(User user, String groupName) { String hashPassword = Hashing.sha256().hashString(user.getPassword(), Charsets.UTF_8).toString(); user.setPassword(hashPassword);// www. j av a 2 s. c o m user.setGroupName(groupName); userdao.create(user); }
From source file:com.googlesource.gerrit.plugins.lfs.locks.PathToLockId.java
@Override public String apply(String path) { HashCode hash = Hashing.sha256().hashString(path, StandardCharsets.UTF_8); return BaseEncoding.base16().lowerCase().encode(hash.asBytes()); }
From source file:org.apache.servicecomb.demo.signature.SignatureUtils.java
public static String genSignature(HttpServletRequestEx requestEx) { Hasher hasher = Hashing.sha256().newHasher(); hasher.putString(requestEx.getRequestURI(), StandardCharsets.UTF_8); for (String paramName : paramNames) { String paramValue = requestEx.getHeader(paramName); if (paramValue != null) { hasher.putString(paramName, StandardCharsets.UTF_8); hasher.putString(paramValue, StandardCharsets.UTF_8); System.out.printf("%s %s\n", paramName, paramValue); }//from ww w.j a v a 2s. co m } if (!StringUtils.startsWithIgnoreCase(requestEx.getContentType(), MediaType.APPLICATION_FORM_URLENCODED)) { byte[] bytes = requestEx.getBodyBytes(); if (bytes != null) { hasher.putBytes(bytes, 0, requestEx.getBodyBytesLength()); } } return hasher.hash().toString(); }
From source file:com.streamsets.pipeline.lib.hashing.HashingUtil.java
public static HashFunction getHasher(String hashAlgorithm) { switch (hashAlgorithm) { case "murmur3_128": return Hashing.murmur3_128(); case "MD5": return Hashing.md5(); case "SHA-1": return Hashing.sha1(); case "SHA-256": return Hashing.sha256(); default://from w ww . ja va 2 s . c om throw new IllegalArgumentException(Utils.format("Unsupported Hashing Algorithm: {}", hashAlgorithm)); } }
From source file:google.registry.security.XsrfTokenManager.java
private static String encodeToken(long creationTime, String scope, String userEmail) { String token = Joiner.on('\t').join(getServerSecret(), userEmail, scope, creationTime); return base64Url() .encode(Hashing.sha256().newHasher(token.length()).putString(token, UTF_8).hash().asBytes()); }
From source file:net.osrg.namazu.ExperimentPattern.java
public ExperimentPattern() { this.hasher = Hashing.sha256().newHasher(); }
From source file:ddf.security.listener.AuditingHttpSessionListener.java
@Override public void sessionCreated(HttpSessionEvent se) { HttpSession session = se.getSession(); SecurityLogger.audit("Session {} created.", Hashing.sha256().hashString(session.getId(), StandardCharsets.UTF_8).toString()); }