當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。