• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

AES encryption algorithm

 
Nitin D Gaur
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Have been trying to get AES encryption and decryption algorithm, in which I can pass the security password as encryption key.

It can be done using



but the thing in here I can not pass my pwn password as encryption key, instead it uses key generated by keygenerator.



Can any body help to give any AES encryption and decryption algorithm, in which a key can be passed.

Nitin
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you don't want a generated key, then don't use the KeyGenerator class :-)

Construct a SecretKeySpec instead, and pass that to the Cipher.init method. If the byte[] is of length 16 you'll get AES-128, if its's of length 32 then AES-256 will be used (assuming your JCE provider supports that).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic