title: Spring Security: Simple Encryption / decryption not working: InvalidKeyException
body: <p>I'm trying to write a very simple program to encrypt and decrypt a string:</p>
  
  <pre><code>    String password = "kdfljxcasd";
      String encodeThat = "Hello World + some special chars!^^-";
      String salt = KeyGenerators.string().generateKey();
      BytesEncryptor encryptor = Encryptors.standard(password, salt);
  
      // breakpoint steping doesn't reach that point - it gets stuck here for some reason... 
      byte[] encrypted = encryptor.encrypt(encodeThat.getBytes());
      byte[] decrypted = encryptor.decrypt(encrypted);
  
      System.out.println("Before encryption: " + encodeThat);     
      System.out.println("Encrypted: " + encrypted.toString());       
      System.out.println("After encryption: " + decrypted.toString());
  </code></pre>
  
  <p>But for some reason I never get an encrypted value. When I call <code>enryptor.encrypt()</code> it never reaches that point.</p>
  
  <p>I'm getting the following exception:</p>
  
  <pre><code>'Unable to initialize due to invalid secret key' java.lang.IllegalArgumentException: Unable to initialize due to invalid secret key
  </code></pre>
  
  <p>What am I doing wrong?</p>