internal error: SHA-1 not available.
843810Sep 4 2003 — edited Sep 10 2003HI,
When i try to run
following code
/*###################code ###########################
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.CipherInputStream;
import javax.crypto.CipherOutputStream;
import java.security.NoSuchAlgorithmException;
import java.security.InvalidKeyException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.BadPaddingException;
import java.security.SecureRandom;
import java.security.Security ;
public class Crypt
{
public static void main(String [] args)
{
try{
Cipher c, d;
String s="Hai it's a test";
KeyGenerator keygen = KeyGenerator.getInstance("DES");
SecretKey key = keygen.generateKey();
c = Cipher.getInstance("DES/ECB/PKCS5Padding");
d = Cipher.getInstance("DES/ECB/PKCS5Padding");
c.init(Cipher.ENCRYPT_MODE, key);
d.init(Cipher.DECRYPT_MODE, key);
byte [] b = s.getBytes();
byte [] ca = d.doFinal(c.doFinal(b));
System.out.println(ca);
}catch(IllegalBlockSizeException i){}
catch(BadPaddingException i){}
catch(NoSuchPaddingException i){}
catch(InvalidKeyException i){}
catch(NoSuchAlgorithmException i){}
}
}
I get following Exception
Exception in thread "main" java.lang.InternalError: internal error: SHA-1 not available.
at sun.security.provider.SecureRandom.init(SecureRandom.java:86)
at sun.security.provider.SecureRandom.<init>(SecureRandom.java:65)
at java.security.SecureRandom.<init>(SecureRandom.java:131)
at com.sun.crypto.provider.SunJCE.<clinit>(DashoA6275)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.ja
va:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:306)
at java.lang.Class.newInstance(Class.java:259)
at java.security.Provider.loadProvider(Provider.java:153)
at java.security.Security$2.run(Security.java:278)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.Security.reloadProviders(Security.java:274)
at java.security.Security.getProviders(Security.java:813)
at java.security.SecureRandom.getPrngAlgorithm(SecureRandom.java:468)
at java.security.SecureRandom.<init>(SecureRandom.java:128)
at javax.crypto.SunJCE_b.<clinit>(DashoA6275)
at javax.crypto.KeyGenerator.getInstance(DashoA6275)
at Crypt.main(Crypt.java:54)
BUT i don't use SHA-1 in my program.I don't know what's the problem.
please can any one help me in this as soon as possible.This exception occurs at whatever crypto functions i call first.
I tried changing the provider to Cryptix also.The problem is also not with Provider.what must be the cause.is there any basic configuration to be done?