List of usage examples for com.google.common.hash HashCode fromBytes
@CheckReturnValue public static HashCode fromBytes(byte[] bytes)
From source file:org.gradle.internal.serialize.HashCodeSerializer.java
@Override public HashCode read(Decoder decoder) throws IOException { byte hashSize = decoder.readByte(); byte[] hash = new byte[hashSize]; decoder.readBytes(hash);//from w w w . ja va 2s . c om return HashCode.fromBytes(hash); }
From source file:com.google.devtools.build.lib.skyframe.serialization.HashCodeCodec.java
@Override public HashCode deserialize(DeserializationContext context, CodedInputStream codedIn) throws SerializationException, IOException { return HashCode.fromBytes(codedIn.readByteArray()); }
From source file:io.mandrel.io.payload.ByteArrayPayload.java
public ByteArrayPayload(byte[] content, byte[] md5) { super(content); contentMetadata().contentLength(Long.valueOf(checkNotNull(content, "content").length)); contentMetadata().contentMd5(md5 == null ? null : HashCode.fromBytes(md5)); checkArgument(content.length >= 0, "length cannot me negative"); }
From source file:org.jclouds.googlecloudstorage.blobstore.functions.ObjectToBlobMetadata.java
private static HashCode toHashCode(@Nullable String hashCode) { return hashCode == null ? null : HashCode.fromBytes(BaseEncoding.base64().decode(hashCode)); }
From source file:com.google.devtools.build.lib.actions.cache.Md5Digest.java
@Override public String toString() { return HashCode.fromBytes(digest).toString(); }
From source file:org.eclipse.che.security.SHA512PasswordEncryptor.java
@Override public String encrypt(String password) { requireNonNull(password, "Required non-null password"); // generate salt final byte[] salt = new byte[SALT_BYTES_LENGTH]; SECURE_RANDOM.nextBytes(salt);/*from ww w .j ava2s. co m*/ // sha512(password + salt) final HashCode hash = Hashing.sha512().hashBytes(Bytes.concat(password.getBytes(PWD_CHARSET), salt)); final HashCode saltHash = HashCode.fromBytes(salt); // add salt to the hash, result length (512 / 8) * 2 + (64 / 8) * 2 = 144 return hash.toString() + saltHash.toString(); }
From source file:org.mule.util.xa.MuleXid.java
@Override public int hashCode() { return formatId * HashCode.fromBytes(globalTransactionId).asInt() * HashCode.fromBytes(branchQualifier).asInt() * 17; }
From source file:com.google.devtools.build.lib.remote.ContentDigests.java
public static String toHexString(ContentDigest digest) { return HashCode.fromBytes(digest.getDigest().toByteArray()).toString(); }
From source file:org.jclouds.io.payloads.BaseMutableContentMetadata.java
/** @deprecated use {@link #setContentMD5(HashCode)} instead. */ @Deprecated/*from w w w . j a va2 s . c o m*/ @Override public void setContentMD5(byte[] md5) { setContentMD5(md5 == null ? null : HashCode.fromBytes(md5)); }
From source file:com.google.devtools.build.lib.remote.MemcacheActionCache.java
@Override public String putFileIfNotExist(Path file) throws IOException { String contentKey = HashCode.fromBytes(file.getMD5Digest()).toString(); if (containsFile(contentKey)) { return contentKey; }/*from www.jav a 2 s . co m*/ putFile(contentKey, file); return contentKey; }