0

I have this code:

class Crypt
{
    Key KEY;
    String TD;
    Cipher aes = Cipher.getInstance("AES/CBC/PKCS5Padding");

    KeyGenerator keyGen = KeyGenerator.getInstance("AES");

public Crypt()
{
    int keyLength = 192;
    keyGen.init(keyLength);
    KEY = keyGen.generateKey();

Which when compiles gives this error:

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    Unhandled exception type NoSuchAlgorithmException
    Unhandled exception type NoSuchPaddingException
    Unhandled exception type NoSuchAlgorithmException

When researching the error I found this. But after downloading, installing and verifying that Unlimited Strength Jurisdiction Policy Files are up to date I am still getting the error.

Community
  • 1
  • 1
owen gerig
  • 6,165
  • 6
  • 52
  • 91
  • just wanted to put a warning for other osx users. it seems to me that if you manually update them from java's website you could end up with other errors. The ones built in should work – owen gerig Jun 08 '12 at 15:02

2 Answers2

2

Your error is very clear and doesn't have anything to do with the unlimited jurisdiction encryption files. It's telling you there are unhandled checked exceptions.

Add throws Exception to your constructor so it looks like this:

public Crypt() throws Exception
{
    int keyLength = 192;
    keyGen.init(keyLength);
    KEY = keyGen.generateKey();
Sarel Botha
  • 12,419
  • 7
  • 54
  • 59
1

Did you also install them into /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/security?

Edvin Syse
  • 7,267
  • 18
  • 24