Package com.google.common.hash

Examples of com.google.common.hash.HashCode.asBytes()


   /** @deprecated use {@link #getContentMD5AsHashCode()} instead. */
   @Deprecated
   @Override
   public byte[] getContentMD5() {
      HashCode hashCode = getContentMD5AsHashCode();
      return hashCode == null ? null : hashCode.asBytes();
   }

   @Override
   public HashCode getContentMD5AsHashCode() {
      return contentMD5;
View Full Code Here


    public static String md5(File file)
    {
        try
        {
            HashCode hc = Files.hash(file, Hashing.md5());
            return toHex(hc.asBytes());
        }
        catch (Exception e)
        {
            throw new RuntimeException(e);
        }
View Full Code Here

        response.addHeader(HttpHeaders.CONTENT_LENGTH,
                contentMetadata.getContentLength().toString());
        response.setContentType(contentMetadata.getContentType());
        HashCode contentMd5 = contentMetadata.getContentMD5AsHashCode();
        if (contentMd5 != null) {
            byte[] contentMd5Bytes = contentMd5.asBytes();
            response.addHeader(HttpHeaders.CONTENT_MD5,
                    BaseEncoding.base64().encode(contentMd5Bytes));
            response.addHeader(HttpHeaders.ETAG, "\"" +
                    BaseEncoding.base16().lowerCase().encode(contentMd5Bytes) +
                    "\"");
View Full Code Here

   * @return 128 bits of hash result
   */
  public byte[] hash(byte[] data) {
    HashCode hashCode = byteArrayHasher.hashBytes(data);

    return hashCode.asBytes();
  }

  public long hashToLong(byte[] data) {
    HashCode hashCode = byteArrayHasher.hashBytes(data);

View Full Code Here

      HashCode hashCode = HashCode.fromBytes(new byte[16]);
      Blob blob = blobFactory.create(null);
      blob.getMetadata().setName("name");
      blob.setPayload("");
      blob.getPayload().getContentMetadata().setContentLength(2l);
      blob.getPayload().getContentMetadata().setContentMD5(hashCode.asBytes());
      blob.getPayload().getContentMetadata().setContentType("text/plain");
      blob.getPayload().getContentMetadata().setExpires(new Date(1000));
     
      HttpRequest request = signer.signPutBlob("container", blob);
View Full Code Here

               "Expect: 100-continue\n" +
               "x-emc-signature: OlAHsoIDCsO5YmqjRxOIM5sp3r0=\n" +
               "x-emc-uid: identity\n" +
               "x-emc-wschecksum: MD5/0/00000000000000000000000000000000\n");

      assertContentHeadersEqual(request, "text/plain", null, null, null, 2L, hashCode.asBytes(), new Date(1000));

      assertEquals(request.getFilters().size(), 0);
   }

   @BeforeClass
View Full Code Here

      }

      HashCode md5 = payload.getContentMetadata().getContentMD5AsHashCode();
      if (md5 != null) {
         // Swift will validate the md5, if placed as an ETag header
         builder.replaceHeader(ETAG, base16().lowerCase().encode(md5.asBytes()));
      }

      Date expires = payload.getContentMetadata().getExpires();
      if (expires != null) {
         builder.addHeader(OBJECT_DELETE_AT,
View Full Code Here

               request,
               "Authorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n" +
               "Content-Length: 2\n" +
               "Content-MD5: AAAAAAAAAAAAAAAAAAAAAA==\n" +
               "Content-Type: text/plain\n");
      assertContentHeadersEqual(request, "text/plain", null, null, null, 2L, hashCode.asBytes(), null);

      assertEquals(request.getFilters().size(), 0);
   }

   public void testSignPutBlobWithGenerate() throws ArrayIndexOutOfBoundsException, SecurityException,
View Full Code Here

      String containerName = getContainerName();
      S3Object object = null;
      try {
         String key = "constitution.txt";
         String uploadId = getApi().initiateMultipartUpload(containerName,
                  ObjectMetadataBuilder.create().key(key).contentMD5(oneHundredOneConstitutionsMD5.asBytes()).build());
         byte[] buffer = oneHundredOneConstitutions.read();
         assertEquals(oneHundredOneConstitutions.size(), (long) buffer.length);

         Payload part1 = newByteArrayPayload(buffer);
         part1.getContentMetadata().setContentLength((long) buffer.length);
View Full Code Here

               "Authorization: SharedKeyLite identity:V0gyrdMZzwQrCvxEfq6eBe8PL233yJ91+aNcISEzjfE=\n" +
               "Date: Thu, 05 Jun 2008 16:38:19 GMT\n" +
               "Expect: 100-continue\n" +
               "x-ms-blob-type: BlockBlob\n" +
               "x-ms-version: 2012-02-12\n");
      assertContentHeadersEqual(request, "text/plain", null, null, null, 2L, hashCode.asBytes(), new Date(1000));

      assertEquals(request.getFilters().size(), 0);
   }

   @BeforeClass
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.