org.spongycastle.crypto.digests.SHA256Digest类的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(197)

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

SHA256Digest介绍

[英]FIPS 180-2 implementation of SHA-256.

block  word  digest 
SHA-1   512    32    160 
SHA-256 512    32    256 
SHA-384 1024   64    384 
SHA-512 1024   64    512

[中]FIPS 180-2 SHA-256的实施

block  word  digest 
SHA-1   512    32    160 
SHA-256 512    32    256 
SHA-384 1024   64    384 
SHA-512 1024   64    512

代码示例

代码示例来源:origin: ethereum/ethereumj

private static EthereumIESEngine makeIESEngine(boolean isEncrypt, ECPoint pub, BigInteger prv, byte[] IV) {
  AESEngine aesFastEngine = new AESEngine();
  EthereumIESEngine iesEngine = new EthereumIESEngine(
      new ECDHBasicAgreement(),
      new ConcatKDFBytesGenerator(new SHA256Digest()),
      new HMac(new SHA256Digest()),
      new SHA256Digest(),
      new BufferedBlockCipher(new SICBlockCipher(aesFastEngine)));
  byte[]         d = new byte[] {};
  byte[]         e = new byte[] {};
  IESParameters p = new IESWithCipherParameters(d, e, KEY_SIZE, KEY_SIZE);
  ParametersWithIV parametersWithIV = new ParametersWithIV(p, IV);
  iesEngine.init(isEncrypt, new ECPrivateKeyParameters(prv, CURVE), new ECPublicKeyParameters(pub, CURVE), parametersWithIV);
  return iesEngine;
}

代码示例来源:origin: com.madgag.spongycastle/core

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);
  }
}

代码示例来源:origin: QuincySx/BlockchainWallet-Crypto

public static byte[] sha256(byte[] bytes, int offset, int size) {
  SHA256Digest sha256Digest = new SHA256Digest();
  sha256Digest.update(bytes, offset, size);
  byte[] sha256 = new byte[32];
  sha256Digest.doFinal(sha256, 0);
  return sha256;
}

代码示例来源:origin: com.madgag.spongycastle/core

X[t] = Theta1(X[t - 2]) + X[t - 7] + Theta0(X[t - 15]) + X[t - 16];
h += Sum1(e) + Ch(e, f, g) + K[t] + X[t];
d += h;
h += Sum0(a) + Maj(a, b, c);
++t;
g += Sum1(d) + Ch(d, e, f) + K[t] + X[t];
c += g;
g += Sum0(h) + Maj(h, a, b);
++t;
f += Sum1(c) + Ch(c, d, e) + K[t] + X[t];
b += f;
f += Sum0(g) + Maj(g, h, a);
++t;
e += Sum1(b) + Ch(b, c, d) + K[t] + X[t];
a += e;
e += Sum0(f) + Maj(f, g, h);
++t;
d += Sum1(a) + Ch(a, b, c) + K[t] + X[t];
h += d;
d += Sum0(e) + Maj(e, f, g);
++t;
c += Sum1(h) + Ch(h, a, b) + K[t] + X[t];
g += c;

代码示例来源:origin: telehash/telehash-java

/**
 * Return a SHA-256 digest of the provided byte buffer.
 *
 * @param buffer The buffer to digest.
 * @return A 32-byte array representing the digest.
 */
@Override
public byte[] sha256Digest(byte[] buffer) {
  SHA256Digest digest = new SHA256Digest();
  digest.update(buffer, 0, buffer.length);
  byte[] output = new byte[256/8];
  digest.doFinal(output, 0);
  return output;
}

代码示例来源:origin: com.madgag/sc-light-jdk15on

X[t] = Theta1(X[t - 2]) + X[t - 7] + Theta0(X[t - 15]) + X[t - 16];
h += Sum1(e) + Ch(e, f, g) + K[t] + X[t];
d += h;
h += Sum0(a) + Maj(a, b, c);
++t;
g += Sum1(d) + Ch(d, e, f) + K[t] + X[t];
c += g;
g += Sum0(h) + Maj(h, a, b);
++t;
f += Sum1(c) + Ch(c, d, e) + K[t] + X[t];
b += f;
f += Sum0(g) + Maj(g, h, a);
++t;
e += Sum1(b) + Ch(b, c, d) + K[t] + X[t];
a += e;
e += Sum0(f) + Maj(f, g, h);
++t;
d += Sum1(a) + Ch(a, b, c) + K[t] + X[t];
h += d;
d += Sum0(e) + Maj(e, f, g);
++t;
c += Sum1(h) + Ch(h, a, b) + K[t] + X[t];
g += c;

代码示例来源:origin: ethereum/ethereumj

public static byte[] decrypt(ECPoint ephem, BigInteger prv, byte[] IV, byte[] cipher, byte[] macData) throws InvalidCipherTextException {
  AESEngine aesFastEngine = new AESEngine();
  EthereumIESEngine iesEngine = new EthereumIESEngine(
      new ECDHBasicAgreement(),
      new ConcatKDFBytesGenerator(new SHA256Digest()),
      new HMac(new SHA256Digest()),
      new SHA256Digest(),
      new BufferedBlockCipher(new SICBlockCipher(aesFastEngine)));
  byte[]         d = new byte[] {};
  byte[]         e = new byte[] {};
  IESParameters p = new IESWithCipherParameters(d, e, KEY_SIZE, KEY_SIZE);
  ParametersWithIV parametersWithIV =
      new ParametersWithIV(p, IV);
  iesEngine.init(false, new ECPrivateKeyParameters(prv, CURVE), new ECPublicKeyParameters(ephem, CURVE), parametersWithIV);
  return iesEngine.processBlock(cipher, 0, cipher.length, macData);
}

代码示例来源:origin: ethereum/ethereumj

throw new MissingPrivateKeyException();
if (privKey instanceof BCECPrivateKey) {
  ECDSASigner signer = new ECDSASigner(new HMacDSAKCalculator(new SHA256Digest()));
  ECPrivateKeyParameters privKeyParams = new ECPrivateKeyParameters(((BCECPrivateKey) privKey).getD(), CURVE);
  signer.init(true, privKeyParams);

代码示例来源:origin: ethereum/ethereumj

private static EthereumIESEngine makeIESEngine(boolean isEncrypt, ECPoint pub, BigInteger prv, byte[] IV) {
  AESEngine aesFastEngine = new AESEngine();
  EthereumIESEngine iesEngine = new EthereumIESEngine(
      new ECDHBasicAgreement(),
      new ConcatKDFBytesGenerator(new SHA256Digest()),
      new HMac(new SHA256Digest()),
      new SHA256Digest(),
      new BufferedBlockCipher(new SICBlockCipher(aesFastEngine)));
  byte[]         d = new byte[] {};
  byte[]         e = new byte[] {};
  IESParameters p = new IESWithCipherParameters(d, e, KEY_SIZE, KEY_SIZE);
  ParametersWithIV parametersWithIV = new ParametersWithIV(p, IV);
  iesEngine.init(isEncrypt, new ECPrivateKeyParameters(prv, curve), new ECPublicKeyParameters(pub, curve), parametersWithIV);
  return iesEngine;
}

代码示例来源:origin: ethereum/ethereumj

@Test
public void testKDF() {
  ConcatKDFBytesGenerator kdf = new ConcatKDFBytesGenerator(new SHA256Digest());
  kdf.init(new KDFParameters("Hello".getBytes(), new byte[0]));
  byte[] bytes = new byte[2];
  kdf.generateBytes(bytes, 0, bytes.length);
  assertArrayEquals(new byte[]{-66, -89}, bytes);
}

代码示例来源:origin: ethereum/ethereumj

new KDF2BytesGenerator(new SHA256Digest()),
new HMac(new SHA256Digest()),
new BufferedBlockCipher(new SICBlockCipher(aesFastEngine)));
new KDF2BytesGenerator (new SHA256Digest()),
new HMac(new SHA256Digest()),
new BufferedBlockCipher(new SICBlockCipher(aesFastEngine)));

代码示例来源:origin: ethereum/ethereumj

new KDF2BytesGenerator(new SHA256Digest()),
new HMac(new SHA256Digest()),
new BufferedBlockCipher(new SICBlockCipher(aesFastEngine)));
new KDF2BytesGenerator (new SHA256Digest()),
new HMac(new SHA256Digest()),
new BufferedBlockCipher(new SICBlockCipher(aesFastEngine)));

代码示例来源:origin: com.madgag.spongycastle/prov

public Digest()
{
  super(new SHA256Digest());
}

代码示例来源:origin: com.madgag.spongycastle/prov

private static Digest getDigest(AlgorithmIdentifier algId)
  {
    return new SHA256Digest();
  }
}

代码示例来源:origin: com.madgag.spongycastle/core

public static Digest createSHA256()
{
  return new SHA256Digest();
}

代码示例来源:origin: com.madgag.spongycastle/bcpkix-jdk15on

public ExtendedDigest get(AlgorithmIdentifier digestAlgorithmIdentifier)
  {
    return new SHA256Digest();
  }
});

代码示例来源:origin: com.madgag.spongycastle/pkix

public ExtendedDigest get(AlgorithmIdentifier digestAlgorithmIdentifier)
  {
    return new SHA256Digest();
  }
});

代码示例来源:origin: com.madgag.spongycastle/bcpkix-jdk15on

public ExtendedDigest get(AlgorithmIdentifier digestAlgorithmIdentifier)
  {
    return new SHA256Digest();
  }
});

代码示例来源:origin: com.madgag.spongycastle/core

public Memoable copy()
{
  return new SHA256Digest(this);
}

代码示例来源:origin: com.madgag/scprov-jdk15on

public Digest()
{
  super(new SHA256Digest());
}

相关文章