JDK1.2/JCE1.2

samir nasser (snasser@sciquest.com)
Thu, 3 Dec 1998 12:58:00 -0500

Hi everybody, I downloaded JDK1.2, JCE1.2, JavaMail1.1 and Jaf1.0
recently to develop a servlet that sends encrypted E-mail. Very soon, I
got frustrated. I tried to conpile the following program:

import javax.crypto.*;
import java.security.*;

public class Encrypt {

public static void main(String[] args) throws Exception {

Cipher desCipher;

KeyGenerator keyGen = KeyGenerator.getInstance("DES");
SecretKey desKey = keyGen.generateKey();

desCipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
desCipher.init(Cipher.ENCRYPT_MODE, desKey);

byte[] clearText = "This is just an example".getBytes();

System.out.println(String.valueOf(clearText));

byte[] cipherText = desCipher.doFinal(clearText);

desCipher.init(Cipher.DECRYPT_MODE, desKey);

byte[] clearText1 = desCipher.doFinal(cipherText);
}
}

I got the following compiler error:

Encrypt.java:6: Class java.security.GeneralSecurityException not found
in class Encrypt. Then, I unarchived the source codes and realised that
java.security package is there, so I compiled it and put a reference to
the classes in the CLASSPATH. I recompiled the program. This time, it
compiled fine without an error.

When I went to run the program, I got the following error:

Exception in thread "main" java.lang.InternalError: internal error:
SHA-1 not available.
at sun.security.provider.SecureRandom.init(SecureRandom.java:93)
at sun.security.provider.SecureRandom.(init)(SecureRandom.java:72)
at java.security.SecureRandom.(init)(SecureRandom.java:132)
at com.sun.crypto.provider.DESKeyGenerator.engineGeneratorKey(Compiled
Code)
at javax.crypto.KeyGenerator.generateKey(KeyGenerator.java:278)
at Encrypt.main(Encrypt.java:11)

Please help me resolve this problem. I would really appreciate that!

Have a good day!