当前位置: 首页>>代码示例>>Java>>正文


Java SHA3Digest类代码示例

本文整理汇总了Java中org.bouncycastle.crypto.digests.SHA3Digest的典型用法代码示例。如果您正苦于以下问题:Java SHA3Digest类的具体用法?Java SHA3Digest怎么用?Java SHA3Digest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SHA3Digest类属于org.bouncycastle.crypto.digests包,在下文中一共展示了SHA3Digest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: clone

import org.bouncycastle.crypto.digests.SHA3Digest; //导入依赖的package包/类
public Object clone()
    throws CloneNotSupportedException
{
    BCMessageDigest d = (BCMessageDigest)super.clone();
    d.digest = new SHA3Digest((SHA3Digest)digest);

    return d;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:9,代码来源:SHA3.java

示例2: getSha3Hash

import org.bouncycastle.crypto.digests.SHA3Digest; //导入依赖的package包/类
public static String getSha3Hash(String data) {
    String trimmedData = trimNewLines(data);
    byte[] dataBytes = trimmedData.getBytes();
    SHA3Digest md = new SHA3Digest(256);
    md.reset();
    md.update(dataBytes, 0, dataBytes.length);
    byte[] hashedBytes = new byte[256 / 8];
    md.doFinal(hashedBytes, 0);
    String sha3Hash = ByteUtils.toHexString(hashedBytes);
    return sha3Hash;
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:12,代码来源:EncryptionUtil.java

示例3: initDigesters

import org.bouncycastle.crypto.digests.SHA3Digest; //导入依赖的package包/类
private static void initDigesters() {
	digesters.put("Blake2b", Blake2bDigest.class);
	digesters.put("GOST3411", GOST3411Digest.class);
	digesters.put("Keccak", KeccakDigest.class);
	digesters.put("MD2", MD2Digest.class);
	digesters.put("MD4", MD4Digest.class);
	digesters.put("MD5", MD5Digest.class);
	digesters.put("RIPEMD128", RIPEMD128Digest.class);
	digesters.put("RIPEMD160", RIPEMD160Digest.class);
	digesters.put("RIPEMD256", RIPEMD256Digest.class);
	digesters.put("RIPEMD320", RIPEMD320Digest.class);
	digesters.put("SHA1", SHA1Digest.class);
	digesters.put("SHA224", SHA224Digest.class);
	digesters.put("SHA256", SHA256Digest.class);
	digesters.put("SHA384", SHA384Digest.class);
	digesters.put("SHA3-512", SHA3Digest.class);
	digesters.put("SHA3-256", SHA3Digest.class);
	digesters.put("SHA3-224", SHA3Digest.class);
	digesters.put("SHA3-384", SHA3Digest.class);
	digesters.put("SHA512", SHA512Digest.class);
	digesters.put("SHAKE-128", SHAKEDigest.class);
	digesters.put("SHAKE-256", SHAKEDigest.class);
	digesters.put("Skein256", SkeinDigest.class);
	digesters.put("Skein512", SkeinDigest.class);
	digesters.put("Skein1024", SkeinDigest.class);
	digesters.put("SM3", SM3Digest.class);
	digesters.put("Tiger", TigerDigest.class);
	digesters.put("Whirlpool", WhirlpoolDigest.class);
}
 
开发者ID:shilongdai,项目名称:vsDiaryWriter,代码行数:30,代码来源:Digesters.java

示例4: getHashDigest

import org.bouncycastle.crypto.digests.SHA3Digest; //导入依赖的package包/类
private Digest getHashDigest() {
    if ("SHA3".equals(hashAlgorithm)) {
        return new SHA3Digest();
    } else {
        // Default to SHA2
        return new SHA256Digest();
    }
}
 
开发者ID:hyperledger,项目名称:fabric-sdk-java,代码行数:9,代码来源:CryptoPrimitives.java

示例5: generateParameterHash

import org.bouncycastle.crypto.digests.SHA3Digest; //导入依赖的package包/类
/**
 * Generate parameter hash for the given chaincode path,func and args
 *
 * @param path Chaincode path
 * @param func Chaincode function name
 * @param args List of arguments
 * @return hash of path, func and args
 */
public static String generateParameterHash(String path, String func, List<String> args) {
    logger.debug(String.format("GenerateParameterHash : path=%s, func=%s, args=%s", path, func, args));

    // Append the arguments
    StringBuilder param = new StringBuilder(path);
    param.append(func);
    args.forEach(param::append);

    // Compute the hash

    return Hex.toHexString(hash(param.toString().getBytes(UTF_8), new SHA3Digest()));
}
 
开发者ID:hyperledger,项目名称:fabric-sdk-java,代码行数:21,代码来源:Utils.java

示例6: generateDirectoryHash

import org.bouncycastle.crypto.digests.SHA3Digest; //导入依赖的package包/类
/**
 * Generate hash of a chaincode directory
 *
 * @param rootDir      Root directory
 * @param chaincodeDir Channel code directory
 * @param hash         Previous hash (if any)
 * @return hash of the directory
 * @throws IOException
 */
public static String generateDirectoryHash(String rootDir, String chaincodeDir, String hash) throws IOException {
    // Generate the project directory
    Path projectPath = null;
    if (rootDir == null) {
        projectPath = Paths.get(chaincodeDir);
    } else {
        projectPath = Paths.get(rootDir, chaincodeDir);
    }

    File dir = projectPath.toFile();
    if (!dir.exists() || !dir.isDirectory()) {
        throw new IOException(String.format("The chaincode path \"%s\" is invalid", projectPath));
    }

    StringBuilder hashBuilder = new StringBuilder(hash);
    Files.walk(projectPath)
            .sorted(Comparator.naturalOrder())
            .filter(Files::isRegularFile)
            .map(Path::toFile)
            .forEach(file -> {
                try {
                    byte[] buf = readFile(file);
                    byte[] toHash = Arrays.concatenate(buf, hashBuilder.toString().getBytes(UTF_8));
                    hashBuilder.setLength(0);
                    hashBuilder.append(Hex.toHexString(hash(toHash, new SHA3Digest())));
                } catch (IOException ex) {
                    throw new RuntimeException(String.format("Error while reading file %s", file.getAbsolutePath()), ex);
                }
            });

    // If original hash and final hash are the same, it indicates that no new contents were found
    if (hashBuilder.toString().equals(hash)) {
        throw new IOException(String.format("The chaincode directory \"%s\" has no files", projectPath));
    }
    return hashBuilder.toString();
}
 
开发者ID:hyperledger,项目名称:fabric-sdk-java,代码行数:46,代码来源:Utils.java

示例7: testGenerateParameterHash

import org.bouncycastle.crypto.digests.SHA3Digest; //导入依赖的package包/类
@Test
public void testGenerateParameterHash() {
    List<String> args = new ArrayList<>();
    args.add("a");
    args.add("b");
    String hash = Utils.generateParameterHash("mypath", "myfunc", args);
    Assert.assertEquals(Hex.toHexString(Utils.hash("mypathmyfuncab".getBytes(UTF_8), new SHA3Digest())), hash);
}
 
开发者ID:hyperledger,项目名称:fabric-sdk-java,代码行数:9,代码来源:UtilsTest.java

示例8: testHash

import org.bouncycastle.crypto.digests.SHA3Digest; //导入依赖的package包/类
@Test
public void testHash() {

    byte[] input = "TheQuickBrownFox".getBytes(UTF_8);
    String expectedHash = "feb69c5c360a15802de6af23a3f5622da9d96aff2be78c8f188cce57a3549db6";

    byte[] hash = Utils.hash(input, new SHA3Digest());
    Assert.assertEquals(expectedHash, Hex.toHexString(hash));
}
 
开发者ID:hyperledger,项目名称:fabric-sdk-java,代码行数:10,代码来源:UtilsTest.java

示例9: getClusterSignature

import org.bouncycastle.crypto.digests.SHA3Digest; //导入依赖的package包/类
/**
 * Signs the server's public ID with the cluster key.
 */
public static String[] getClusterSignature(String clusterKey) {
  LinkedList<String> rsvValues = new LinkedList<>();
  while (rsvValues.isEmpty()) {
    // Hash the public key
    SHA3Digest sha3 = new SHA3Digest(256);
    sha3.reset();
    sha3.update(Secp256k1.getPublicKey(myKey), 0, Secp256k1.getPublicKey(myKey).length);
    byte[] hashedBytes = new byte[256 / 8];
    sha3.doFinal(hashedBytes, 0);

    // Sign it.
    byte[][] signature =
        Secp256k1.signTransaction(hashedBytes, ByteUtilities.toByteArray(clusterKey));
    Arrays.asList(signature)
        .forEach(sigValue -> rsvValues.add(ByteUtilities.toHexString(sigValue)));

    // Recovery ID is bad, try again.
    if (rsvValues.get(2).equalsIgnoreCase("ff")) {
      LOGGER.debug("Problem getting signature, V is invalid.");
      LOGGER.debug(rsvValues.toString());
      rsvValues.clear();
    }
  }

  return rsvValues.toArray(new String[rsvValues.size()]);
}
 
开发者ID:Braveno,项目名称:cosigner,代码行数:30,代码来源:ServerKey.java

示例10: performTest

import org.bouncycastle.crypto.digests.SHA3Digest; //导入依赖的package包/类
public void performTest()
{
    testDigest(new SHA3Digest(), digests288);
    testDigest(new SHA3Digest(224), digests224);
    testDigest(new SHA3Digest(256), digests256);
    testDigest(new SHA3Digest(384), digests384);
    testDigest(new SHA3Digest(512), digests512);

    testMac(new SHA3Digest(224), macKeys, macData, mac224, trunc224);
    testMac(new SHA3Digest(256), macKeys, macData, mac256, trunc256);
    testMac(new SHA3Digest(384), macKeys, macData, mac384, trunc384);
    testMac(new SHA3Digest(512), macKeys, macData, mac512, trunc512);
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:14,代码来源:SHA3DigestTest.java

示例11: DigestSHA3

import org.bouncycastle.crypto.digests.SHA3Digest; //导入依赖的package包/类
public DigestSHA3(int size)
{
    super(new SHA3Digest(size));
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:5,代码来源:SHA3.java

示例12: HashMac224

import org.bouncycastle.crypto.digests.SHA3Digest; //导入依赖的package包/类
public HashMac224()
{
    super(new HMac(new SHA3Digest(224)));
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:5,代码来源:SHA3.java

示例13: HashMac256

import org.bouncycastle.crypto.digests.SHA3Digest; //导入依赖的package包/类
public HashMac256()
{
    super(new HMac(new SHA3Digest(256)));
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:5,代码来源:SHA3.java

示例14: HashMac384

import org.bouncycastle.crypto.digests.SHA3Digest; //导入依赖的package包/类
public HashMac384()
{
    super(new HMac(new SHA3Digest(384)));
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:5,代码来源:SHA3.java

示例15: HashMac512

import org.bouncycastle.crypto.digests.SHA3Digest; //导入依赖的package包/类
public HashMac512()
{
    super(new HMac(new SHA3Digest(512)));
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:5,代码来源:SHA3.java


注:本文中的org.bouncycastle.crypto.digests.SHA3Digest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。