Re: Java string encryption/decryption



On Sat, 22 Nov 2008 07:48:36 -0800 (PST), dj_uncas <djuncas@xxxxxxxxx>
wrote:

If 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" );
You need to read the Javadoc more carefully. The algorithms for
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?

.



Relevant Pages

  • Re: Pseudorandom keystream ciphers
    ... cipher such as RC4 is wholly dependent on the pseudorandom ... algorithms developed by amateurs. ... I would have to overlay it with a real private key ...
    (sci.crypt)
  • Re: Pseudorandom keystream ciphers
    ... cipher such as RC4 is wholly dependent on the pseudorandom ... The general advice is to avoid hidden algorithms. ... I would have to overlay it with a real private key ...
    (sci.crypt)
  • Simple Unbreakable (Sipher Idea)
    ... to eliminate attackers possibilities for breaking the cipher using ... which the attacker is not assumed ... The algorithms also demonstrate a method, ... produced one-time-pad. ...
    (sci.crypt)
  • Re: triple algorithms
    ... matching of algorithms I would advise you don't do this. ... AES is secure insofar as nobody has yet found a viable attack for it. ... creating a new cipher out of a collection of others. ... security depends only on the single assumption that factoring is hard. ...
    (sci.crypt)