本文整理了Java中org.bouncycastle.crypto.digests.SHA256Digest.update()
方法的一些代码示例,展示了SHA256Digest.update()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SHA256Digest.update()
方法的具体详情如下:
包路径:org.bouncycastle.crypto.digests.SHA256Digest
类名称:SHA256Digest
方法名:update
暂无
代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on
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: redfish64/TinyTravelTracker
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: horrorho/InflatableDonkey
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);
}
}
代码示例来源:origin: org.opendaylight.usc/usc-channel-impl
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;
}
代码示例来源:origin: io.github.in-toto/in-toto
private void collect(String filename) {
FileInputStream file = null;
try {
file = new FileInputStream(filename);
} catch (FileNotFoundException e) {
throw new RuntimeException("The file " + filename + " couldn't be recorded");
}
SHA256Digest digest = new SHA256Digest();
byte[] result = new byte[digest.getDigestSize()];
int length;
try {
while ((length = file.read(result)) != -1) {
digest.update(result, 0, length);
}
} catch (IOException e) {
throw new RuntimeException("The file " + filename + " couldn't be recorded");
}
digest.doFinal(result, 0);
// We should be able to submit more hashes, but we will do sha256
// only for the time being
this.put("sha256", Hex.toHexString(result));
}
}
代码示例来源:origin: horrorho/LiquidDonkey
sha256.update(pad, 0, pad.length);
sha256.update(shared, 0, shared.length);
sha256.update(otherPublicKey, 0, otherPublicKey.length);
sha256.update(myPublicKey, 0, myPublicKey.length);
sha256.doFinal(hash, 0);
代码示例来源:origin: io.github.in-toto/in-toto
/**
* Convenience method to obtain the keyid for this key
*
* @return the keyid for this key (Sha256 is baked in, for the time being)
*/
public String computeKeyId() {
if (this.kpr == null)
return null;
byte[] JSONrepr = getJSONEncodeableFields();
// initialize digest
SHA256Digest digest = new SHA256Digest();
byte[] result = new byte[digest.getDigestSize()];
digest.update(JSONrepr, 0, JSONrepr.length);
digest.doFinal(result, 0);
return Hex.toHexString(result);
}
代码示例来源:origin: stackoverflow.com
SHA256Digest digester = new SHA256Digest();
byte[] retValue = new byte[digester.getDigestSize()];
digester.update(key.getBytes(), 0, key.length());
digester.doFinal(retValue,0);
内容来源于网络,如有侵权,请联系作者删除!