List of usage examples for com.google.common.hash Hashing md5
public static HashFunction md5()
From source file:teetime.stage.MD5Stage.java
@Override protected void execute(final String element) { Hasher hasher = Hashing.md5().newHasher(); hasher.putString(element, charset);//from www. j a v a 2 s . c o m outputPort.send(hasher.hash().toString()); }
From source file:com.tw.go.sample.descriptorhash.DescriptorHash.java
@Load public void onLoad(PluginContext context) { logger.info("Creating a hasher....."); HashFunction hashFunction = Hashing.md5(); hasher = hashFunction.newHasher(); }
From source file:com.google.idea.blaze.android.run.binary.instantrun.BlazeInstantRunGradleIntegration.java
/** * Gets a unique directory for a given target that can be used for the build process. */// ww w .j a va 2s . c o m static File getInstantRunArtifactDirectory(Project project, Label target) { BlazeImportSettings importSettings = BlazeImportSettingsManager.getInstance(project).getImportSettings(); assert importSettings != null; File dataSubDirectory = new File(importSettings.getProjectDataDirectory(), ModuleDataStorage.DATA_SUBDIRECTORY); File instantRunDirectory = new File(dataSubDirectory, INSTANT_RUN_SUBDIRECTORY); String targetHash = Hashing.md5().hashUnencodedChars(target.toString()).toString(); return new File(instantRunDirectory, targetHash); }
From source file:uk.ac.ebi.fg.annotare2.core.files.LocalFileHandle.java
@Override public String getDigest() throws IOException { if (null == digest) { digest = Files.hash(file, Hashing.md5()).toString(); }/*from w w w .j a v a 2 s.c o m*/ return digest; }
From source file:co.cask.cdap.logging.appender.kafka.StringPartitioner.java
@Override public int partition(String key, int numPartitions) { return Math.abs(Hashing.md5().hashString(key).asInt()) % this.numPartitions; }
From source file:cn.exinhua.fetch.entity.Link.java
public void setUrl(String url) { this.url = url; this.hash = Hashing.md5().newHasher().putString(url, Charsets.UTF_8).hash().toString(); }
From source file:org.gradle.cache.internal.CacheRepositoryServices.java
protected CacheKeyBuilder createCacheKeyBuilder(FileHasher fileHasher, ClassPathSnapshotter snapshotter, ClassLoaderHierarchyHasher classLoaderHierarchyHasher) { return new DefaultCacheKeyBuilder(Hashing.md5(), fileHasher, snapshotter, classLoaderHierarchyHasher); }
From source file:de.ebf.AbstractOneSkyAppMojo.java
String getAuthParams() { final long timestamp = System.currentTimeMillis() / 1000; final String devHash = Hashing.md5().hashString(timestamp + secretKey, StandardCharsets.UTF_8).toString(); return String.format("api_key=%1$s×tamp=%2$s&dev_hash=%3$s", publicKey, timestamp, devHash); }
From source file:com.medallia.spider.sttools.CachedTool.java
@Override public String render(StringTemplate st) { String resourceName = String.valueOf(st.getAttribute("it")); StaticResource sr = srl.findStaticResource(resourceName); if (sr != null) { // copy into buffer and calculate md5 ByteArrayOutputStream buffer = new ByteArrayOutputStream(); try {//from w w w . j av a 2s . c o m sr.copyTo(buffer); } catch (IOException e) { throw new RuntimeException(e); } // create and return link String md5 = Hashing.md5().hashBytes(buffer.toByteArray()).toString(); return resourceName + "?" + md5; } throw new RuntimeException("Resource not found: " + resourceName); }
From source file:co.cask.cdap.data2.transaction.queue.QueueEntryRow.java
/** * Returns a byte array representing prefix of a queue. The prefix is formed by first byte of * MD5 of the queue name followed by the queue name. *///from w w w. ja v a 2 s.c o m private static byte[] getQueueRowPrefix(byte[] queueIdWithinFlow) { byte[] bytes = new byte[queueIdWithinFlow.length + 1]; Hashing.md5().hashBytes(queueIdWithinFlow).writeBytesTo(bytes, 0, 1); System.arraycopy(queueIdWithinFlow, 0, bytes, 1, queueIdWithinFlow.length); return bytes; }