當前位置: 首頁>>代碼示例>>Java>>正文


Java MessageDigest.clone方法代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:tencentyun,項目名稱:cos-java-sdk-v5,代碼行數:8,代碼來源:MD5DigestCalculatingInputStream.java

示例2: supportsClone

import java.security.MessageDigest; //導入方法依賴的package包/類
private static boolean supportsClone(MessageDigest digest) {
  try {
    digest.clone();
    return true;
  } catch (CloneNotSupportedException e) {
    return false;
  }
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:9,代碼來源:MessageDigestHashFunction.java

示例3: initCloneableMd5

import java.security.MessageDigest; //導入方法依賴的package包/類
private static MessageDigest initCloneableMd5(){
	try{
		MessageDigest messageDigest = createMd5Instance();
		messageDigest.clone();
		return messageDigest;
	}catch(CloneNotSupportedException ignore){
		return null;
	}
}
 
開發者ID:hotpads,項目名稱:datarouter,代碼行數:10,代碼來源:HashMethods.java

示例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;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:51,代碼來源:TestCloning.java


注:本文中的java.security.MessageDigest.clone方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。