Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3294
  • Last Modified:

Java crypto - Illegal key size or default parameters

Hey guys,

I'm running into some trouble loading a key into a cipher to encrypt some strings.  Below is the line of code that's causing an issue.

Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.ENCRYPT_MODE, secretKey);

where secretKey contains 256 bytes.

I'm getting a java.security.InvalidKeyException: Illegal key size or default parameters.

I've scoured the internet and have come to believe this is an environment issue - I'm assuming I need to install JCE (Java Cryptography Extensions), but am running out of luck getting anything to work (most of the better documentation are around 8 years old).

I'll start off by saying I have Eclipse Standard/SDK installed, Version Kepler Service Release 1.  Are there any set up gurus out there that could assist me in resolving this issue?
0
larrysy
Asked:
larrysy
  • 3
  • 2
1 Solution
 
CEHJCommented:
I'm assuming I need to install JCE (Java Cryptography Extensions)
That's a possibility. Did you?
0
 
krakatoaCommented:
>where secretKey contains 256 bytes.

Bits?

Think 128 might be the limit.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
larrysyAuthor Commented:
Turns out I had pulled the wrong version of JCE.
0
 
CEHJCommented:
:)
0
 
krakatoaCommented:
So the limit was 128-bit, correct?
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now