本文整理匯總了Java中org.bouncycastle.crypto.Digest.reset方法的典型用法代碼示例。如果您正苦於以下問題:Java Digest.reset方法的具體用法?Java Digest.reset怎麽用?Java Digest.reset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bouncycastle.crypto.Digest
的用法示例。
在下文中一共展示了Digest.reset方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: calculateHashForZeroKnowledgeProof
import org.bouncycastle.crypto.Digest; //導入方法依賴的package包/類
private static BigInteger calculateHashForZeroKnowledgeProof(
BigInteger g,
BigInteger gr,
BigInteger gx,
String participantId,
Digest digest)
{
digest.reset();
updateDigestIncludingSize(digest, g);
updateDigestIncludingSize(digest, gr);
updateDigestIncludingSize(digest, gx);
updateDigestIncludingSize(digest, participantId);
byte[] output = new byte[digest.getDigestSize()];
digest.doFinal(output, 0);
return new BigInteger(output);
}
示例2: calculateMacKey
import org.bouncycastle.crypto.Digest; //導入方法依賴的package包/類
/**
* Calculates the MacKey (i.e. the key to use when calculating the MagTag for key confirmation).
* <p/>
* <p/>
* <pre>
* MacKey = H(K || "JPAKE_KC")
* </pre>
*/
private static byte[] calculateMacKey(BigInteger keyingMaterial, Digest digest)
{
digest.reset();
updateDigest(digest, keyingMaterial);
/*
* This constant is used to ensure that the macKey is NOT the same as the derived key.
*/
updateDigest(digest, "JPAKE_KC");
byte[] output = new byte[digest.getDigestSize()];
digest.doFinal(output, 0);
return output;
}
示例3: OAEPEncoding
import org.bouncycastle.crypto.Digest; //導入方法依賴的package包/類
public OAEPEncoding(
AsymmetricBlockCipher cipher,
Digest hash,
Digest mgf1Hash,
byte[] encodingParams)
{
this.engine = cipher;
this.mgf1Hash = mgf1Hash;
this.defHash = new byte[hash.getDigestSize()];
hash.reset();
if (encodingParams != null)
{
hash.update(encodingParams, 0, encodingParams.length);
}
hash.doFinal(defHash, 0);
}
示例4: hash
import org.bouncycastle.crypto.Digest; //導入方法依賴的package包/類
public static byte[] hash(HashAlgoType hashAlgoType, byte[] data) {
ParamUtil.requireNonNull("hashAlgoType", hashAlgoType);
ParamUtil.requireNonNull("data", data);
if (!MDS_MAP.containsKey(hashAlgoType)) {
throw new IllegalArgumentException("unknown hash algo " + hashAlgoType);
}
ConcurrentBag<ConcurrentBagEntry<Digest>> mds = MDS_MAP.get(hashAlgoType);
ConcurrentBagEntry<Digest> md0 = null;
for (int i = 0; i < 3; i++) {
try {
md0 = mds.borrow(10, TimeUnit.SECONDS);
break;
} catch (InterruptedException ex) { // CHECKSTYLE:SKIP
}
}
if (md0 == null) {
throw new RuntimeOperatorException("could not get idle MessageDigest");
}
try {
Digest md = md0.value();
md.reset();
md.update(data, 0, data.length);
byte[] bytes = new byte[md.getDigestSize()];
md.doFinal(bytes, 0);
return bytes;
} finally {
mds.requite(md0);
}
}
示例5: hash
import org.bouncycastle.crypto.Digest; //導入方法依賴的package包/類
/**
* Hash the data and returns the first 8 bytes of the hash value.
* @param data data over which the hash value is calculated.
* @return long represented of the first 8 bytes
*/
public static long hash(byte[] data) {
ParamUtil.requireNonNull("data", data);
ConcurrentBagEntry<Digest> md0 = null;
for (int i = 0; i < 3; i++) {
try {
md0 = MDS.borrow(10, TimeUnit.SECONDS);
break;
} catch (InterruptedException ex) { // CHECKSTYLE:SKIP
}
}
if (md0 == null) {
throw new RuntimeOperatorException("could not get idle MessageDigest");
}
try {
Digest md = md0.value();
md.reset();
md.update(data, 0, data.length);
byte[] bytes = new byte[md.getDigestSize()];
md.doFinal(bytes, 0);
return bytesToLong(bytes);
} finally {
MDS.requite(md0);
}
}
示例6: modifyBytes
import org.bouncycastle.crypto.Digest; //導入方法依賴的package包/類
public byte[] modifyBytes(byte[] input) throws ModificationException{
// Get the selected ByteModifier and use the modifyBytes method from their to update input.
Digest digest;
byte[] output;
if (algoComboBox.getSelectedItem().equals("MD2")) {
digest = new MD2Digest();
output = new byte[digest.getDigestSize()];
} else if (algoComboBox.getSelectedItem().equals("MD4")) {
digest = new MD4Digest();
output = new byte[digest.getDigestSize()];
} else if (algoComboBox.getSelectedItem().equals("MD5")) {
digest = new MD5Digest();
output = new byte[digest.getDigestSize()];
} else if (algoComboBox.getSelectedItem().equals("Keccak")) {
digest = new KeccakDigest(Integer.parseInt((String)keccakComboBox.getSelectedItem()));
output = new byte[digest.getDigestSize()];
} else if (algoComboBox.getSelectedItem().equals("RIPEMD128")) {
digest = new RIPEMD128Digest();
output = new byte[digest.getDigestSize()];
} else if (algoComboBox.getSelectedItem().equals("RIPEMD160")) {
digest = new RIPEMD160Digest();
output = new byte[digest.getDigestSize()];
} else if (algoComboBox.getSelectedItem().equals("RIPEMD256")) {
digest = new RIPEMD256Digest();
output = new byte[digest.getDigestSize()];
} else if (algoComboBox.getSelectedItem().equals("RIPEMD320")) {
digest = new RIPEMD320Digest();
output = new byte[digest.getDigestSize()];
} else if (algoComboBox.getSelectedItem().equals("SHA1")) {
digest = new SHA1Digest();
output = new byte[digest.getDigestSize()];
} else if (algoComboBox.getSelectedItem().equals("SHA224")) {
digest = new SHA224Digest();
output = new byte[digest.getDigestSize()];
} else if (algoComboBox.getSelectedItem().equals("SHA256")) {
digest = new SHA256Digest();
output = new byte[digest.getDigestSize()];
} else if (algoComboBox.getSelectedItem().equals("SHA384")) {
digest = new SHA384Digest();
output = new byte[digest.getDigestSize()];
} else if (algoComboBox.getSelectedItem().equals("SHA3")) {
digest = new SHA3Digest(Integer.parseInt((String)sha3ComboBox.getSelectedItem()));
output = new byte[digest.getDigestSize()];
} else if (algoComboBox.getSelectedItem().equals("SHAKE")) {
digest = new SHAKEDigest(Integer.parseInt((String)shakeComboBox.getSelectedItem()));
output = new byte[digest.getDigestSize()];
} else if (algoComboBox.getSelectedItem().equals("SM3")) {
digest = new SM3Digest();
output = new byte[digest.getDigestSize()];
} else if (algoComboBox.getSelectedItem().equals("Tiger")) {
digest = new TigerDigest();
output = new byte[digest.getDigestSize()];
} else if (algoComboBox.getSelectedItem().equals("GOST3411")) {
digest = new GOST3411Digest();
output = new byte[digest.getDigestSize()];
} else {
digest = new WhirlpoolDigest();
output = new byte[digest.getDigestSize()];
}
// KeccakDigest 224, 256, 288, 384, 512
// SHA3Digest 224, 256, 384, 512
// SHAKEDigest 128, 256
digest.reset();
digest.update(input, 0, input.length);
digest.doFinal(output, 0);
return output;
}