本文整理汇总了Java中java.security.MessageDigest.clone方法的典型用法代码示例。如果您正苦于以下问题:Java MessageDigest.clone方法的具体用法?Java MessageDigest.clone怎么用?Java MessageDigest.clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.security.MessageDigest
的用法示例。
在下文中一共展示了MessageDigest.clone方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cloneFrom
import java.security.MessageDigest; //导入方法依赖的package包/类
private MessageDigest cloneFrom(MessageDigest from) {
try {
return (MessageDigest)from.clone();
} catch (CloneNotSupportedException e) { // should never occur
throw new IllegalStateException("unexpected", e);
}
}
示例2: supportsClone
import java.security.MessageDigest; //导入方法依赖的package包/类
private static boolean supportsClone(MessageDigest digest) {
try {
digest.clone();
return true;
} catch (CloneNotSupportedException e) {
return false;
}
}
示例3: initCloneableMd5
import java.security.MessageDigest; //导入方法依赖的package包/类
private static MessageDigest initCloneableMd5(){
try{
MessageDigest messageDigest = createMd5Instance();
messageDigest.clone();
return messageDigest;
}catch(CloneNotSupportedException ignore){
return null;
}
}
示例4: testCloning
import java.security.MessageDigest; //导入方法依赖的package包/类
private static MessageDigest testCloning(MessageDigest mdObj, Provider p)
throws Exception {
// copy#0: clone at state BLANK w/o any data
MessageDigest mdCopy0 = (MessageDigest) mdObj.clone();
// copy#1: clone again at state BUFFERED w/ very short data
mdObj.update(data1);
mdCopy0.update(data1);
MessageDigest mdCopy1 = (MessageDigest) mdObj.clone();
// copy#2: clone again after updating it w/ long data to trigger
// the state into INIT
mdObj.update(data2);
mdCopy0.update(data2);
mdCopy1.update(data2);
MessageDigest mdCopy2 = (MessageDigest) mdObj.clone();
// copy#3: clone again after updating it w/ very short data
mdObj.update(data1);
mdCopy0.update(data1);
mdCopy1.update(data1);
mdCopy2.update(data1);
MessageDigest mdCopy3 = (MessageDigest) mdObj.clone();
// copy#4: clone again after updating it w/ long data
mdObj.update(data2);
mdCopy0.update(data2);
mdCopy1.update(data2);
mdCopy2.update(data2);
mdCopy3.update(data2);
MessageDigest mdCopy4 = (MessageDigest) mdObj.clone();
// check digest equalities
byte[] answer = mdObj.digest();
byte[] result0 = mdCopy0.digest();
byte[] result1 = mdCopy1.digest();
byte[] result2 = mdCopy2.digest();
byte[] result3 = mdCopy3.digest();
byte[] result4 = mdCopy4.digest();
check(answer, result0, "copy0");
check(answer, result1, "copy1");
check(answer, result2, "copy2");
check(answer, result3, "copy3");
check(answer, result4, "copy4");
return mdCopy3;
}