Java Code Examples for java.security.MessageDigest#clone()
The following examples show how to use
java.security.MessageDigest#clone() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MessageDigest2Test.java From j2objc with Apache License 2.0 | 6 votes |
/** * java.security.MessageDigest#clone() */ public void test_clone() throws Exception { for (Entry<Provider, List<String>> e : digestAlgs.entrySet()) { for (String algorithm : e.getValue()) { MessageDigest d1 = MessageDigest.getInstance(algorithm, e.getKey().getName()); for (byte b = 0; b < 84; b++) { d1.update(b); } MessageDigest d2 = (MessageDigest) d1.clone(); d1.update((byte) 1); d2.update((byte) 1); assertTrue("cloned hash differs from original for algorithm " + algorithm, MessageDigest.isEqual(d1.digest(), d2.digest())); } } }
Example 2
Source File: MD5DigestCalculatingInputStream.java From markdown-image-kit with MIT License | 5 votes |
private MessageDigest cloneFrom(MessageDigest from) { try { return (MessageDigest)from.clone(); } catch (CloneNotSupportedException e) { // should never occur throw new IllegalStateException("unexpected", e); } }
Example 3
Source File: MD5DigestCalculatingInputStream.java From cos-java-sdk-v5 with MIT License | 5 votes |
private MessageDigest cloneFrom(MessageDigest from) { try { return (MessageDigest)from.clone(); } catch (CloneNotSupportedException e) { // should never occur throw new IllegalStateException("unexpected", e); } }
Example 4
Source File: TestCloning.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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; }
Example 5
Source File: Md5Checksum.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
private MessageDigest cloneFrom(MessageDigest from) { try { return (MessageDigest) from.clone(); } catch (CloneNotSupportedException e) { // should never occur throw new IllegalStateException("unexpected", e); } }
Example 6
Source File: MD5DigestCalculatingInputStream.java From ibm-cos-sdk-java with Apache License 2.0 | 5 votes |
private static boolean canBeCloned(MessageDigest digest) { try { digest.clone(); return true; } catch (CloneNotSupportedException e) { return false; } }
Example 7
Source File: MD5DigestCalculatingInputStream.java From ibm-cos-sdk-java with Apache License 2.0 | 5 votes |
private MessageDigest cloneFrom(MessageDigest from) { try { return (MessageDigest)from.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Message digest implementation does not support cloning.", e); } }
Example 8
Source File: MessageDigestHashFunction.java From exonum-java-binding with Apache License 2.0 | 5 votes |
private static boolean supportsClone(MessageDigest digest) { try { digest.clone(); return true; } catch (CloneNotSupportedException e) { return false; } }
Example 9
Source File: MessageDigestHashFunction.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private static boolean supportsClone(MessageDigest digest) { try { digest.clone(); return true; } catch (CloneNotSupportedException e) { return false; } }
Example 10
Source File: MessageDigestHashFunction.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private static boolean supportsClone(MessageDigest digest) { try { digest.clone(); return true; } catch (CloneNotSupportedException e) { return false; } }
Example 11
Source File: MessageDigestHashFunction.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private static boolean supportsClone(MessageDigest digest) { try { digest.clone(); return true; } catch (CloneNotSupportedException e) { return false; } }
Example 12
Source File: MessageDigestHashFunction.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private static boolean supportsClone(MessageDigest digest) { try { digest.clone(); return true; } catch (CloneNotSupportedException e) { return false; } }
Example 13
Source File: MessageDigestHashFunction.java From codebuff with BSD 2-Clause "Simplified" License | 5 votes |
private static boolean supportsClone(MessageDigest digest) { try { digest.clone(); return true; } catch (CloneNotSupportedException e) { return false; } }
Example 14
Source File: DigestHashFunction.java From bazel with Apache License 2.0 | 5 votes |
private static boolean supportsClone(MessageDigest toCheck) { try { toCheck.clone(); return true; } catch (CloneNotSupportedException e) { return false; } }