本文整理汇总了Java中org.apache.commons.codec.digest.DigestUtils.sha256方法的典型用法代码示例。如果您正苦于以下问题:Java DigestUtils.sha256方法的具体用法?Java DigestUtils.sha256怎么用?Java DigestUtils.sha256使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.codec.digest.DigestUtils
的用法示例。
在下文中一共展示了DigestUtils.sha256方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculateHash
import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
/**
* Calculates the hash using relevant fields of this type
* @return SHA256-hash as raw bytes
*/
public byte[] calculateHash() {
byte[] hashableData = ArrayUtils.addAll(text.getBytes(), senderHash);
hashableData = ArrayUtils.addAll(hashableData, signature);
hashableData = ArrayUtils.addAll(hashableData, Longs.toByteArray(timestamp));
return DigestUtils.sha256(hashableData);
}
示例2: calculateHash
import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
/**
* Calculates the hash using relevant fields of this type
* @return SHA256-hash as raw bytes
*/
public byte[] calculateHash() {
byte[] hashableData = ArrayUtils.addAll(previousBlockHash, merkleRoot);
hashableData = ArrayUtils.addAll(hashableData, Longs.toByteArray(tries));
hashableData = ArrayUtils.addAll(hashableData, Longs.toByteArray(timestamp));
return DigestUtils.sha256(hashableData);
}
示例3: prepareKeyMap
import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
/**
* Load the private Keymap with the x5t256 thumbprint and the public key
* The map only contains a single key
* @return
* @throws Exception
*/
private Map<String, RSAPublicKey> prepareKeyMap() throws Exception
{
Map<String, RSAPublicKey> keys = new HashMap<>();
Certificate cert = getCertificate();
RSAPublicKey key = (RSAPublicKey)cert.getPublicKey();
byte[] x5tS256 = DigestUtils.sha256(cert.getEncoded());
String b64x5tS256 = org.apache.commons.codec.binary.Base64.encodeBase64URLSafeString(x5tS256);
keys.put(b64x5tS256, key);
return keys;
}
示例4: calculateHash
import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
/**
* Calculates the hash using relevant fields of this type
* @return SHA256-hash as raw bytes
*/
private byte[] calculateHash() {
byte[] hashableData = ArrayUtils.addAll(name.getBytes(), publicKey);
return DigestUtils.sha256(hashableData);
}
示例5: getShortkey
import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
/**
* Calculates a text key 8 characters or shorter. Resulting key is URL and JSON safe.
* Current formula is substr(base64(sha256(value)),1,8), but in the future it
* might start returning the actual input string if it is shorter than 8 chars.
*
* @param value - string to be hashed
* @return A string in base 64, 8 chars or shorter.
*/
public static String getShortkey(String value) {
byte[] hash = DigestUtils.sha256(value);
String hashString = IdConverterUtils.convertByteArrayToBase64String(hash,null);
return hashString.substring(0, 8);
}