本文整理匯總了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;
}