use of com.google.common.hash.Hasher in project gradle by gradle.
the class DefaultClasspathEntryHasher method hashZipEntry.
private HashCode hashZipEntry(InputStream inputStream, ZipEntry zipEntry, ClasspathContentHasher classpathContentHasher) throws IOException {
Hasher hasher = new TrackingHasher(Hashing.md5().newHasher());
classpathContentHasher.appendContent(zipEntry.getName(), inputStream, hasher);
return hasher.hash();
}
use of com.google.common.hash.Hasher in project gradle by gradle.
the class ExternalRepositoryResourceAccessor method withResource.
@Override
public void withResource(String relativePath, Action<? super InputStream> action) {
try {
String scheme = rootUri.getScheme();
String host = rootUri.getHost();
String path = makePath(rootUri.getPath());
int port = rootUri.getPort();
String userInfo = rootUri.getUserInfo();
URI uri = new URI(scheme, userInfo, host, port, path + relativePath, null, null);
Hasher hasher = Hashing.sha1().newHasher().putString(uri.toASCIIString(), Charsets.UTF_8);
final String key = hasher.hash().toString();
LocallyAvailableExternalResource resource = resourceAccessor.getResource(uri, new CacheAwareExternalResourceAccessor.ResourceFileStore() {
@Override
public LocallyAvailableResource moveIntoCache(File downloadedResource) {
return fileStore.move(key, downloadedResource);
}
}, null);
if (resource != null) {
resource.withContent(action);
}
} catch (Exception e) {
throw UncheckedException.throwAsUncheckedException(e);
}
}
use of com.google.common.hash.Hasher in project riposte by Nike-Inc.
the class VerifyMultipartRequestsWorkComponentTest method getHashForMultipartPayload.
private static String getHashForMultipartPayload(String name, String filename, byte[] payloadBytes) {
Hasher hasher = hashFunction.newHasher().putString(name, Charsets.UTF_8);
if (filename != null)
hasher = hasher.putString(filename, Charsets.UTF_8);
hasher = hasher.putBytes(payloadBytes);
HashCode hc = hasher.hash();
return hc.toString();
}
use of com.google.common.hash.Hasher in project riposte by Nike-Inc.
the class VerifyPayloadHandlingComponentTest method getHashForPayload.
/**
* @return The MD5 hash of the given payload. This can be used to verify correctness when sending payloads across the wire.
*/
private static String getHashForPayload(byte[] payloadBytes) {
Hasher hasher = hashFunction.newHasher();
hasher = hasher.putBytes(payloadBytes);
HashCode hc = hasher.hash();
return hc.toString();
}
use of com.google.common.hash.Hasher in project phoenix by apache.
the class SkipScanFilter method hashCode.
@Override
public int hashCode() {
HashFunction hf = Hashing.goodFastHash(32);
Hasher h = hf.newHasher();
h.putInt(slots.size());
for (int i = 0; i < slots.size(); i++) {
h.putInt(slots.get(i).size());
for (int j = 0; j < slots.size(); j++) {
h.putBytes(slots.get(i).get(j).getLowerRange());
h.putBytes(slots.get(i).get(j).getUpperRange());
}
}
return h.hash().asInt();
}
Aggregations