Package java.security

Examples of java.security.MessageDigest.clone()


        try
          {
            md1 = MessageDigest.getInstance(mdName, Registry.GNU_SECURITY);

            md1.update(abc); // start with abc
            md2 = (MessageDigest) md1.clone(); // now clone it

            ba1 = md1.digest(in); // now finish both with in
            ba2 = md2.digest(in);

            harness.check(Arrays.equals(ba1, ba2), "testCloneability(" + mdName
View Full Code Here


    private static MessageDigest createMessageDigest(Ruby runtime, String providerName) throws NoSuchAlgorithmException {
        MessageDigest cloneable = CLONEABLE_DIGESTS.get(providerName);
        if (cloneable != null) {
            try {
                return (MessageDigest)cloneable.clone();
            } catch (CloneNotSupportedException cnse) {
                // should never happen, since we tested it in static init
            }
        }
View Full Code Here

    private static MessageDigest createMessageDigest(Ruby runtime, String providerName) throws NoSuchAlgorithmException {
        MessageDigest cloneable = CLONEABLE_DIGESTS.get(providerName);
        if (cloneable != null) {
            try {
                return (MessageDigest)cloneable.clone();
            } catch (CloneNotSupportedException cnse) {
                // should never happen, since we tested it in static init
            }
        }
View Full Code Here

 
  public static String hash(String str, String algorithm, int numIterations,char[] encoding) throws NoSuchAlgorithmException {
    try {
      MessageDigest md=MessageDigest.getInstance(algorithm),mdc;
      for(int i=0;i<numIterations;i++){
        mdc=(MessageDigest) md.clone();
        mdc.reset();
          mdc.update(toBytes(str, CharsetUtil.UTF8));
          str=new String(enc(mdc.digest(),encoding));
      }
      return str;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.