本文整理汇总了Java中org.spongycastle.util.Arrays.areEqual方法的典型用法代码示例。如果您正苦于以下问题:Java Arrays.areEqual方法的具体用法?Java Arrays.areEqual怎么用?Java Arrays.areEqual使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongycastle.util.Arrays
的用法示例。
在下文中一共展示了Arrays.areEqual方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getValueAt
import org.spongycastle.util.Arrays; //导入方法依赖的package包/类
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
if(columnIndex == 0) {
return Hex.toHexString(data.get(rowIndex).address);
}
else if(columnIndex == 1 ){
if(data.get(rowIndex).accountState != null) {
return Denomination.toFriendlyString(data.get(rowIndex).accountState.getBalance());
}
return "---";
}
else {
if(data.get(rowIndex).accountState != null) {
if(!Arrays.areEqual(data.get(rowIndex).accountState.getCodeHash(), HashUtil.EMPTY_DATA_HASH))
return "Yes";
}
return "No";
}
}
示例2: decryptAes
import org.spongycastle.util.Arrays; //导入方法依赖的package包/类
public String decryptAes(String iv, String ciphertext) throws
InvalidAlgorithmParameterException, InvalidKeyException, BadPaddingException,
IllegalBlockSizeException, UnsupportedEncodingException, InvalidCipherTextException,
NoSuchAlgorithmException {
this.iv = Hex.decode(iv);
byte[] ctext = Hex.decode(ciphertext);
// This "ciphertext" that we import is constructed from actual_ciphertext + hmacsha1(iv + actual_ciphertext)
byte[] ctextb = Arrays.copyOfRange(ctext, 0, ctext.length - 32);
byte[] mac = Arrays.copyOfRange(ctext, ctext.length - 32, ctext.length);
// Recreate the hmac and verify it matches.
Mac hmac = Mac.getInstance("HmacSHA256");
hmac.init(this.hmacSecretKey);
if (!Arrays.areEqual(mac, hmac.doFinal(Arrays.concatenate(this.iv, ctextb)))) {
throw new RuntimeException("Invalid authentication code: ciphertext may have been tampered with.");
}
// Decrypt the actual_ciphertext.
CipherParameters ivAndKey = new ParametersWithIV(new KeyParameter(aesKey), this.iv);
decryptCipher.init(false, ivAndKey);
return new String(cipherData(decryptCipher, ctextb), UTF_8);
}
示例3: verify
import org.spongycastle.util.Arrays; //导入方法依赖的package包/类
@Override
public boolean verify(SignedUnblinded s, DataItemContent privateData,
RSAKeyParameters publicKey) {
byte[] msg = s.getContent().toByteArray();
if (privateData != null) {
byte[] original = privateData.toByteArray();
if (!Arrays.areEqual(msg, original)) {
return false;
}
}
BigInteger val = new BigInteger(s.getSignature().toByteArray());
val = val.subtract(new BigInteger("100"));
byte[] fromSig = val.toByteArray();
return Arrays.areEqual(msg, fromSig);
}
示例4: toString
import org.spongycastle.util.Arrays; //导入方法依赖的package包/类
public String toString() {
String ret = "Nonce: " + this.getNonce().toString() + "\n" +
"Balance: " + Denomination.toFriendlyString(getBalance()) + "\n";
if(this.getStateRoot()!= null && !Arrays.areEqual(this.getStateRoot(), EMPTY_BYTE_ARRAY))
ret += "State Root: " + Hex.toHexString(this.getStateRoot()) + "\n";
if(this.getCodeHash() != null && !Arrays.areEqual(this.getCodeHash(), EMPTY_DATA_HASH))
ret += "Code Hash: " + Hex.toHexString(this.getCodeHash());
return ret;
}
示例5: verify
import org.spongycastle.util.Arrays; //导入方法依赖的package包/类
@Override
public boolean verify(SignedUnblinded s, DataItemContent privateData,
RSAKeyParameters publicKey) {
byte[] msg = s.getContent().toByteArray();
if (privateData != null) {
byte[] original = privateData.toByteArray();
if (!Arrays.areEqual(msg, original)) {
return false;
}
}
signer.init(false, publicKey);
signer.update(msg, 0, msg.length);
return signer.verifySignature(s.getSignature().toByteArray());
}
示例6: isEqual
import org.spongycastle.util.Arrays; //导入方法依赖的package包/类
public boolean isEqual(Block block) {
return Arrays.areEqual(this.getHash(), block.getHash());
}
示例7: checkExpectedRoot
import org.spongycastle.util.Arrays; //导入方法依赖的package包/类
private void checkExpectedRoot(byte[] expectedRoot, byte[] calculatedRoot) {
if (!Arrays.areEqual(expectedRoot, calculatedRoot)) {
logger.error("Transactions trie root validation failed for block #{}", this.header.getNumber());
panicProcessor.panic("txroot", String.format("Transactions trie root validation failed for block %d %s", this.header.getNumber(), Hex.toHexString(this.header.getHash())));
}
}
示例8: isParentOf
import org.spongycastle.util.Arrays; //导入方法依赖的package包/类
/**
* check if param block is son of this block
*
* @param block - possible a son of this
* @return - true if this block is parent of param block
*/
public boolean isParentOf(Block block) {
return Arrays.areEqual(this.getHash(), block.getParentHash());
}