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


Java SHA256Digest.doFinal方法代码示例

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


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

示例1: deriveSessionKey

import org.bouncycastle.crypto.digests.SHA256Digest; //导入方法依赖的package包/类
private static BigInteger deriveSessionKey(BigInteger keyingMaterial)
{
    /*
     * You should use a secure key derivation function (KDF) to derive the session key.
     * 
     * For the purposes of this example, I'm just going to use a hash of the keying material.
     */
    SHA256Digest digest = new SHA256Digest();
    
    byte[] keyByteArray = keyingMaterial.toByteArray();
    
    byte[] output = new byte[digest.getDigestSize()];
    
    digest.update(keyByteArray, 0, keyByteArray.length);

    digest.doFinal(output, 0);

    return new BigInteger(output);
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:20,代码来源:JPAKEExample.java

示例2: curve25519Unwrap

import org.bouncycastle.crypto.digests.SHA256Digest; //导入方法依赖的package包/类
public static Optional<byte[]> curve25519Unwrap(
        byte[] myPublicKey,
        byte[] myPrivateKey,
        byte[] otherPublicKey,
        byte[] wrappedKey) {

    SHA256Digest sha256 = new SHA256Digest();

    byte[] shared = Curve25519.agreement(otherPublicKey, myPrivateKey);
    logger.debug("-- curve25519Unwrap() - shared agreement: 0x{}", Hex.toHexString(shared));

    // Stripped down NIST SP 800-56A KDF.
    byte[] counter = new byte[]{0x00, 0x00, 0x00, 0x01};
    byte[] hash = new byte[sha256.getDigestSize()];

    sha256.reset();
    sha256.update(counter, 0, counter.length);
    sha256.update(shared, 0, shared.length);
    sha256.update(otherPublicKey, 0, otherPublicKey.length);
    sha256.update(myPublicKey, 0, myPublicKey.length);
    sha256.doFinal(hash, 0);

    logger.debug("-- curve25519Unwrap() - kek: {}", Hex.toHexString(hash));
    return RFC3394Wrap.unwrapAES(hash, wrappedKey);
}
 
开发者ID:horrorho,项目名称:InflatableDonkey,代码行数:26,代码来源:KeyBlobCurve25519Unwrap.java

示例3: main

import org.bouncycastle.crypto.digests.SHA256Digest; //导入方法依赖的package包/类
public static void main(String args[]) {
    byte[] digest = new byte[4096];
    for (int i = 0; i < digest.length; i++) {
        digest[i] = (byte)i;
    }

    long start = JVM.monotonicTimeMillis();
    for (int i = 0; i < 20; i++) {
        SHA256Digest digester = new SHA256Digest();
        byte[] retValue = new byte[digester.getDigestSize()];
        for (int j = 0; j < UPDATES; j++) {
            digester.update(digest, 0, digest.length);
        }
        digester.doFinal(retValue, 0);
    }
    long time = JVM.monotonicTimeMillis() - start;
    System.out.println("BouncyCastleSHA256: " + time);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:19,代码来源:BouncyCastleSHA256.java

示例4: test

import org.bouncycastle.crypto.digests.SHA256Digest; //导入方法依赖的package包/类
public void test(TestHarness th) {
    SHA256Digest md = new SHA256Digest();
    byte[] retValue = new byte[md.getDigestSize()];

    for (int i = 0; i < messages.length; i++) {
        byte[] bytes = messages[i].getBytes();
        md.update(bytes, 0, bytes.length);
        md.doFinal(retValue, 0);
        th.check(Util.hexEncode(retValue).toLowerCase(), digests[i]);
    }

    for (int i = 0; i < 1000000; i++) {
        md.update((byte)'a');
    }
    md.doFinal(retValue, 0);
    th.check(Util.hexEncode(retValue).toLowerCase(), MILLION_A_DIGEST);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:18,代码来源:TestBouncyCastleSHA256.java

示例5: generatePackPoint

import org.bouncycastle.crypto.digests.SHA256Digest; //导入方法依赖的package包/类
private ECPoint generatePackPoint(SHA256Digest digest, byte[] ballot, byte[] hash)
{
    BigInteger element;
    ECPoint point;
    do
    {
        digest.update(seed, 0, seed.length);

        for (int b = 0; b != ballot.length; b++)
        {
            digest.update(ballot[b]);
        }

        digest.doFinal(hash, 0);

        digest.update(hash, 0, hash.length);

        element = new BigInteger(1, hash).mod(domainParameters.getN());
        point = domainParameters.getG().multiply(element).normalize();
    }
    while (element.equals(BigInteger.ZERO) || packMap.containsKey(point));
    return point;
}
 
开发者ID:cwgit,项目名称:ximix,代码行数:24,代码来源:PackedBallotTableBuilder.java

示例6: computeChallenge

import org.bouncycastle.crypto.digests.SHA256Digest; //导入方法依赖的package包/类
private BigInteger computeChallenge(ECPoint a, ECPoint b, ECPoint c, ECPoint partial, ECPoint g, ECPoint q)
{
    SHA256Digest sha256 = new SHA256Digest();

    addIn(sha256, a);
    addIn(sha256, b);
    addIn(sha256, c);

    addIn(sha256, partial);
    addIn(sha256, g);
    addIn(sha256, q);

    byte[] res = new byte[sha256.getDigestSize()];

    sha256.doFinal(res, 0);

    return new BigInteger(1, res);
}
 
开发者ID:cwgit,项目名称:ximix,代码行数:19,代码来源:ECDecryptionProof.java

示例7: computeChallenge

import org.bouncycastle.crypto.digests.SHA256Digest; //导入方法依赖的package包/类
private BigInteger computeChallenge(ECPoint a, ECPoint b, ECPoint c, ECPair partial, ECPoint g)
{
    SHA256Digest sha256 = new SHA256Digest();

    addIn(sha256, a);
    addIn(sha256, b);
    addIn(sha256, c);

    addIn(sha256, partial.getX());
    addIn(sha256, g);
    addIn(sha256, q);

    byte[] res = new byte[sha256.getDigestSize()];

    sha256.doFinal(res, 0);

    return new BigInteger(1, res);
}
 
开发者ID:cwgit,项目名称:ximix,代码行数:19,代码来源:ProofGenerator.java

示例8: sha256DigestOf

import org.bouncycastle.crypto.digests.SHA256Digest; //导入方法依赖的package包/类
private static byte[] sha256DigestOf(byte[] input) {
    SHA256Digest d = new SHA256Digest();
    d.update(input,
             0,
             input.length);
    byte[] result = new byte[d.getDigestSize()];
    d.doFinal(result,
              0);
    return result;
}
 
开发者ID:Zubnix,项目名称:rtcdcjava,代码行数:11,代码来源:RTCCertificate.java

示例9: calcHash

import org.bouncycastle.crypto.digests.SHA256Digest; //导入方法依赖的package包/类
private byte[] calcHash(byte[] input, AtomicLong counter) {
    SHA256Digest digest = new SHA256Digest();

    byte[] result = new byte[digest.getDigestSize()];
    digest.update(ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN).putLong(counter.getAndIncrement()).array(), 0, 8);
    digest.update(input, 0, input.length);
    digest.update(this.key, 0, this.key.length);
    digest.doFinal(result, 0);

    return Arrays.copyOf(result, 8);
}
 
开发者ID:JungleTree,项目名称:JungleTree,代码行数:12,代码来源:ProtocolEncryption.java

示例10: hashSHA256

import org.bouncycastle.crypto.digests.SHA256Digest; //导入方法依赖的package包/类
private byte[] hashSHA256(byte[]... message) {
    SHA256Digest digest = new SHA256Digest();

    byte[] result = new byte[digest.getDigestSize()];
    for (byte[] bytes : message) {
        digest.update(bytes, 0, bytes.length);
    }
    digest.doFinal(result, 0);

    return result;
}
 
开发者ID:JungleTree,项目名称:JungleTree,代码行数:12,代码来源:ProtocolEncryption.java

示例11: sha256Digest

import org.bouncycastle.crypto.digests.SHA256Digest; //导入方法依赖的package包/类
public static byte[] sha256Digest(byte[] input) {
  SHA256Digest digest = new SHA256Digest();
  digest.update(input, 0, input.length);
  byte[] result = new byte[digest.getDigestSize()];
  digest.doFinal(result, 0);
  return result;
}
 
开发者ID:google,项目名称:webauthndemo,代码行数:8,代码来源:Crypto.java

示例12: SHA256hash

import org.bouncycastle.crypto.digests.SHA256Digest; //导入方法依赖的package包/类
/************
 * This is the SHA-256 hashing function that is performed on the public key
 * @param tobeHashed - Byte Array that will be hashed
 * @return - The hashed Byte Array is returned in a Byte Array
 */
private byte[] SHA256hash(byte[] tobeHashed){
		SHA256Digest digester=new SHA256Digest(); 
		byte[] retValue=new byte[digester.getDigestSize()]; 
		digester.update(tobeHashed, 0, tobeHashed.length); 
		digester.doFinal(retValue, 0);
	    return retValue; 
}
 
开发者ID:wisdomcsharp,项目名称:SSI_Bitcoin-Storage,代码行数:13,代码来源:Address.java

示例13: calcHash

import org.bouncycastle.crypto.digests.SHA256Digest; //导入方法依赖的package包/类
private byte[] calcHash( byte[] input, AtomicLong counter ) {
    SHA256Digest digest = new SHA256Digest();

    byte[] result = new byte[digest.getDigestSize()];
    digest.update( ByteBuffer.allocate( 8 ).order( ByteOrder.LITTLE_ENDIAN ).putLong( counter.getAndIncrement() ).array(), 0, 8 );
    digest.update( input, 0, input.length );
    digest.update( this.key, 0, this.key.length );
    digest.doFinal( result, 0 );

    return Arrays.copyOf( result, 8 );
}
 
开发者ID:GoMint,项目名称:GoMint,代码行数:12,代码来源:EncryptionHandler.java

示例14: hashSHA256

import org.bouncycastle.crypto.digests.SHA256Digest; //导入方法依赖的package包/类
private byte[] hashSHA256( byte[]... message ) {
    SHA256Digest digest = new SHA256Digest();

    byte[] result = new byte[digest.getDigestSize()];
    for ( byte[] bytes : message ) {
        digest.update( bytes, 0, bytes.length );
    }

    digest.doFinal( result, 0 );

    return result;
}
 
开发者ID:GoMint,项目名称:GoMint,代码行数:13,代码来源:EncryptionHandler.java

示例15: calcHash

import org.bouncycastle.crypto.digests.SHA256Digest; //导入方法依赖的package包/类
private byte[] calcHash( byte[] input, byte[] key, AtomicLong counter ) {
    SHA256Digest digest = new SHA256Digest();

    byte[] result = new byte[digest.getDigestSize()];
    digest.update( ByteBuffer.allocate( 8 ).order( ByteOrder.LITTLE_ENDIAN ).putLong( counter.getAndIncrement() ).array(), 0, 8 );
    digest.update( input, 0, input.length );
    digest.update( key, 0, key.length );
    digest.doFinal( result, 0 );

    return Arrays.copyOf( result, 8 );
}
 
开发者ID:GoMint,项目名称:Proxy,代码行数:12,代码来源:EncryptionHandler.java


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