当前位置: 首页>>代码示例>>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;未经允许,请勿转载。