Re: Java string encryption/decryption
- From: rossum <rossum48@xxxxxxxxxxxx>
- Date: Sat, 22 Nov 2008 17:54:15 +0000
On Sat, 22 Nov 2008 07:48:36 -0800 (PST), dj_uncas <djuncas@xxxxxxxxx>
wrote:
You need to read the Javadoc more carefully. The algorithms forIf that doesn't work then show more code.
It didn't... I found that it isn't the Cipher that throws the
NoSuchAlgorithmException, but the KeyGenerator.getInstance(). My code
looks like this:
KeyGenerator kg = KeyGenerator.getInstance( "AES/CBC/PKCS5Padding" );
KeyGenerator.getInstance() are not the same as for
Cipher.getInstance() Key generation does not involve a mode or
padding:
KeyGenerator kg = KeyGenerator.getInstance( "AES" );
System.out.println( kg.getProvider().getName() );
SecretKey key = kg.generateKey();
Cipher c = Cipher.getInstance( "AES/CBC/PKCS5Padding" );
c.init( mode, key );
byte[] result = c.doFinal( input );
Are you retrieving the generated key?
AlgorithmParameters ap = c.getParameters();
Without it you will not be able to decrypt. The same key is needed on
the decrypting machine.
Can you spot something?
.
- Follow-Ups:
- Re: Java string encryption/decryption
- From: dj_uncas
- Re: Java string encryption/decryption
- References:
- Java string encryption/decryption
- From: dj_uncas
- Re: Java string encryption/decryption
- From: rossum
- Re: Java string encryption/decryption
- From: dj_uncas
- Re: Java string encryption/decryption
- From: rossum
- Re: Java string encryption/decryption
- From: dj_uncas
- Re: Java string encryption/decryption
- From: rossum
- Re: Java string encryption/decryption
- From: dj_uncas
- Java string encryption/decryption
- Prev by Date: Re: Matrix performance question
- Next by Date: Re: Java string encryption/decryption
- Previous by thread: Re: Java string encryption/decryption
- Next by thread: Re: Java string encryption/decryption
- Index(es):
Relevant Pages
|