Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Keystore and Encryption

Posts: 7
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have a scenario where I am encrypting and decrypting a string using Cypher by using SecretKey. I am storing SecretKey (AES type) into a keystore (JCEKS type keystore) by using a small java code and retriving that key for encryption and decryption.
But when i try to use key (RSA type) from keystore (JKS type) generated using "keytool" i am getting exception : Wrong format: RAW bytes needed
at com.sun.crypto.provider.SunJCE_h.a(DashoA12275)
at com.sun.crypto.provider.AESCipher.engineInit(DashoA12275)
at javax.crypto.Cipher.init(DashoA12275)

The command i have used to generate keystore using keytool : keytool -genkey -alias key3 -keyalg RSA -keystore teststore.jks -storepass tspassword

Please explain me, weather it is possible to use the key generated using keytool for encryption and decryption?
If so please explain me.

CLUCK LIKE A CHICKEN! Now look at this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!