com.google.common.hash.Hashing.hmacSha512()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(134)

本文整理了Java中com.google.common.hash.Hashing.hmacSha512()方法的一些代码示例,展示了Hashing.hmacSha512()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Hashing.hmacSha512()方法的具体详情如下:
包路径:com.google.common.hash.Hashing
类名称:Hashing
方法名:hmacSha512

Hashing.hmacSha512介绍

[英]Returns a hash function implementing the Message Authentication Code (MAC) algorithm, using the SHA-512 (512 hash bits) hash function and the given secret key.
[中]使用SHA-512(512个哈希位)哈希函数和给定的密钥返回实现消息身份验证码(MAC)算法的哈希函数。

代码示例

代码示例来源:origin: google/guava

/**
 * Returns a hash function implementing the Message Authentication Code (MAC) algorithm, using the
 * SHA-512 (512 hash bits) hash function and a {@link SecretKeySpec} created from the given byte
 * array and the SHA-512 algorithm.
 *
 *
 * @param key the key material of the secret key
 * @since 20.0
 */
public static HashFunction hmacSha512(byte[] key) {
 return hmacSha512(new SecretKeySpec(checkNotNull(key), "HmacSHA512"));
}

代码示例来源:origin: google/j2objc

/**
 * Returns a hash function implementing the Message Authentication Code (MAC) algorithm, using the
 * SHA-512 (512 hash bits) hash function and a {@link SecretKeySpec} created from the given byte
 * array and the SHA-512 algorithm.
 *
 *
 * @param key the key material of the secret key
 * @since 20.0
 */
public static HashFunction hmacSha512(byte[] key) {
 return hmacSha512(new SecretKeySpec(checkNotNull(key), "HmacSHA512"));
}

代码示例来源:origin: wildfly/wildfly

/**
 * Returns a hash function implementing the Message Authentication Code (MAC) algorithm, using the
 * SHA-512 (512 hash bits) hash function and a {@link SecretKeySpec} created from the given byte
 * array and the SHA-512 algorithm.
 *
 *
 * @param key the key material of the secret key
 * @since 20.0
 */
public static HashFunction hmacSha512(byte[] key) {
 return hmacSha512(new SecretKeySpec(checkNotNull(key), "HmacSHA512"));
}

代码示例来源:origin: prestodb/presto

@Description("Compute HMAC with SHA512")
  @ScalarFunction
  @SqlType(StandardTypes.VARBINARY)
  public static Slice hmacSha512(@SqlType(StandardTypes.VARBINARY) Slice slice, @SqlType(StandardTypes.VARBINARY) Slice key)
  {
    return wrappedBuffer(Hashing.hmacSha512(key.getBytes()).hashBytes(slice.getBytes()).asBytes());
  }
}

代码示例来源:origin: google/guava

public void testToString() {
 byte[] keyData = "secret key".getBytes(UTF_8);
 assertEquals(
   "Hashing.hmacMd5(Key[algorithm=HmacMD5, format=RAW])", Hashing.hmacMd5(MD5_KEY).toString());
 assertEquals(
   "Hashing.hmacMd5(Key[algorithm=HmacMD5, format=RAW])", Hashing.hmacMd5(keyData).toString());
 assertEquals(
   "Hashing.hmacSha1(Key[algorithm=HmacSHA1, format=RAW])",
   Hashing.hmacSha1(SHA1_KEY).toString());
 assertEquals(
   "Hashing.hmacSha1(Key[algorithm=HmacSHA1, format=RAW])",
   Hashing.hmacSha1(keyData).toString());
 assertEquals(
   "Hashing.hmacSha256(Key[algorithm=HmacSHA256, format=RAW])",
   Hashing.hmacSha256(SHA256_KEY).toString());
 assertEquals(
   "Hashing.hmacSha256(Key[algorithm=HmacSHA256, format=RAW])",
   Hashing.hmacSha256(keyData).toString());
 assertEquals(
   "Hashing.hmacSha512(Key[algorithm=HmacSHA512, format=RAW])",
   Hashing.hmacSha512(SHA512_KEY).toString());
 assertEquals(
   "Hashing.hmacSha512(Key[algorithm=HmacSHA512, format=RAW])",
   Hashing.hmacSha512(keyData).toString());
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

/**
 * Returns a hash function implementing the Message Authentication Code (MAC) algorithm, using the
 * SHA-512 (512 hash bits) hash function and a {@link SecretKeySpec} created from the given byte
 * array and the SHA-512 algorithm.
 *
 *
 * @param key the key material of the secret key
 * @since 20.0
 */
public static HashFunction hmacSha512(byte[] key) {
 return hmacSha512(new SecretKeySpec(checkNotNull(key), "HmacSHA512"));
}

代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger

/**
 * Returns a hash function implementing the Message Authentication Code (MAC) algorithm, using the
 * SHA-512 (512 hash bits) hash function and a {@link SecretKeySpec} created from the given byte
 * array and the SHA-512 algorithm.
 *
 *
 * @param key the key material of the secret key
 * @since 20.0
 */
public static HashFunction hmacSha512(byte[] key) {
 return hmacSha512(new SecretKeySpec(checkNotNull(key), "HmacSHA512"));
}

代码示例来源:origin: io.prestosql/presto-main

@Description("Compute HMAC with SHA512")
  @ScalarFunction
  @SqlType(StandardTypes.VARBINARY)
  public static Slice hmacSha512(@SqlType(StandardTypes.VARBINARY) Slice slice, @SqlType(StandardTypes.VARBINARY) Slice key)
  {
    return wrappedBuffer(Hashing.hmacSha512(key.getBytes()).hashBytes(slice.getBytes()).asBytes());
  }
}

代码示例来源:origin: prestosql/presto

@Description("Compute HMAC with SHA512")
  @ScalarFunction
  @SqlType(StandardTypes.VARBINARY)
  public static Slice hmacSha512(@SqlType(StandardTypes.VARBINARY) Slice slice, @SqlType(StandardTypes.VARBINARY) Slice key)
  {
    return wrappedBuffer(Hashing.hmacSha512(key.getBytes()).hashBytes(slice.getBytes()).asBytes());
  }
}

代码示例来源:origin: com.google.guava/guava-tests

public void testToString() {
 byte[] keyData = "secret key".getBytes(UTF_8);
 assertEquals(
   "Hashing.hmacMd5(Key[algorithm=HmacMD5, format=RAW])",
   Hashing.hmacMd5(MD5_KEY).toString());
 assertEquals(
   "Hashing.hmacMd5(Key[algorithm=HmacMD5, format=RAW])",
   Hashing.hmacMd5(keyData).toString());
 assertEquals(
   "Hashing.hmacSha1(Key[algorithm=HmacSHA1, format=RAW])",
   Hashing.hmacSha1(SHA1_KEY).toString());
 assertEquals(
   "Hashing.hmacSha1(Key[algorithm=HmacSHA1, format=RAW])",
   Hashing.hmacSha1(keyData).toString());
 assertEquals(
   "Hashing.hmacSha256(Key[algorithm=HmacSHA256, format=RAW])",
   Hashing.hmacSha256(SHA256_KEY).toString());
 assertEquals(
   "Hashing.hmacSha256(Key[algorithm=HmacSHA256, format=RAW])",
   Hashing.hmacSha256(keyData).toString());
 assertEquals(
   "Hashing.hmacSha512(Key[algorithm=HmacSHA512, format=RAW])",
   Hashing.hmacSha512(SHA512_KEY).toString());
 assertEquals(
   "Hashing.hmacSha512(Key[algorithm=HmacSHA512, format=RAW])",
   Hashing.hmacSha512(keyData).toString());
}

相关文章