[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mozilla-crypto
Subject:    Problem in Message Digest
From:       "Joyce" <joycefan () netvigator ! com>
Date:       2000-10-15 17:47:41
[Download RAW message or body]

I would like to digest a message. However, a compile error is prompted:
Error #: 362 : cyclic inheritance involving class
java.security.MessageDigest at line 30, column 43. It indicates that there
is an error in MessageDigest.getInstance("MD5", "CryptixCrypto").

Please kindly tell me what's going wrong.

My program is shown as follow:

import java.io.*;
import java.security.*;

import sun.misc.BASE64Encoder;
import cryptix.jce.provider.CryptixCrypto;

public class FileHashing {

  private String hashFunc = vSystem.hashFunction;
  private String provider = vSystem.provider;
  private MessageDigest md5;
  private byte[] hash_raw = null;

  public FileHashing () {
    md5 = null;
    hash_raw = null;
  }

  public boolean run(String filename) {
    boolean flag = false;
    try {
//      md = MessageDigest.getInstance(hashFunc, provider);
        Security.addProvider(new CryptixCrypto());
        MessageDigest md5 = MessageDigest.getInstance("MD5",
"CryptixCrypto");
    } catch (NoSuchAlgorithmException nsae) {
      nsae.printStackTrace();
    } catch (NoSuchProviderException nspe){
      nspe.printStackTrace();
    }

    FileInputStream fis = null;

    try {
      fis = new FileInputStream(filename);
      byte[] buffer = new byte [8192];
      int length = 0;
      while ((length = fis.read(buffer)) != -1) {
        md5.update(buffer, 0, length);
      }
      hash_raw = md5.digest();
    } catch (FileNotFoundException fnfe) {
      fnfe.printStackTrace();
    } catch (IOException ioe){
      ioe.printStackTrace();
    }

    BASE64Encoder enc = new BASE64Encoder();
    String base64 = enc.encode(hash_raw);
    System.out.println(base64);
    try {
      FileOutputStream fout = new FileOutputStream(filename + "." +
hashFunc);
      DataOutputStream dout = new DataOutputStream(fout);
      dout.writeBytes(base64);
      dout.close();
      flag = true;
    } catch (FileNotFoundException fnfe) {
      fnfe.printStackTrace();
    } catch (IOException ioe){
      ioe.printStackTrace();
    }

    return flag;
  }
}

Thanks a lot.

Regards,
Joyce

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic