本文整理汇总了Java中org.spongycastle.crypto.digests.SHA512Digest类的典型用法代码示例。如果您正苦于以下问题:Java SHA512Digest类的具体用法?Java SHA512Digest怎么用?Java SHA512Digest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SHA512Digest类属于org.spongycastle.crypto.digests包,在下文中一共展示了SHA512Digest类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDigest
import org.spongycastle.crypto.digests.SHA512Digest; //导入依赖的package包/类
public static Digest getDigest(HashAlgorithmTypes shaType) {
if (shaType.equals(HashAlgorithmTypes.SHA_1)) {
return new SHA1Digest();
}
if (shaType.equals(HashAlgorithmTypes.MD_5)) {
return new MD5Digest();
}
if (shaType.equals(HashAlgorithmTypes.SHA_256)) {
return new SHA256Digest();
}
if (shaType.equals(HashAlgorithmTypes.SHA_384)) {
return new SHA384Digest();
}
if (shaType.equals(HashAlgorithmTypes.SHA_512)) {
return new SHA512Digest();
}
return null;
}
示例2: hash512
import org.spongycastle.crypto.digests.SHA512Digest; //导入依赖的package包/类
public static BigInteger hash512(String id, Object... data){
System.out.println("hash() called with parameters:");
System.out.println(id);
SHA512Digest digest = new SHA512Digest();
digest.update(id.getBytes(), 0, id.getBytes().length);
for(Object obj : data){
if( obj instanceof ECPoint){
byte[] pointData = ((ECPoint) obj).normalize().getEncoded(true);
System.out.println(obj.toString());
digest.update(pointData, 0, pointData.length);
}else if (obj instanceof BigInteger){
byte[] bigIntData = ((BigInteger) obj).toByteArray();
System.out.println(obj.toString());
digest.update(bigIntData, 0, bigIntData.length);
}else{
throw new RuntimeException("Wrong type in hash function: " + obj.getClass().toString());
}
}
byte[] resultBytes = new byte[64];
digest.doFinal(resultBytes, 0);
return new BigInteger(1, resultBytes);
}
示例3: createHmacSha512Digest
import org.spongycastle.crypto.digests.SHA512Digest; //导入依赖的package包/类
static HMac createHmacSha512Digest(byte[] key) {
SHA512Digest digest = new SHA512Digest();
HMac hMac = new HMac(digest);
hMac.init(new KeyParameter(key));
return hMac;
}