Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in encryption using AES with 256bit key

 
Ashok Pradhan
Ranch Hand
Posts: 180
Eclipse IDE Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to encrypt some text using AES with 256bit key but unable to achieve, at runtime it raises an Exception
Exception in thread "main" java.security.InvalidKeyException: Illegal key size or default parameters

When I change to 128 bit key size it works .I have JDK 7 and UnlimitedJCEPolicy is in JDK and JRE as part of JDK 7

my class



Please help

Thanks Ashok
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your code works for me under Ubuntu with JDK1.7.0_21 so I suspect that you do not actually have the 'unlimited strength' files installed in the jdk/jre that is actually being used. Make sure that you are picking up the jdk/jre that you think you are and if you are make sure you have installed the 'unlimited strength' files correctly.

P.S. Turning cipher text into a String using

is in general a sure way to corrupt it. OK you might get away with it for a particular ciphertext but in general you won't.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic