title: AES Salting iterations, How many required?
body: <p>I am trying to execute a simple Encrypt and Decrypt AES and I was trying to use salting. These values will be stored in the DB and retrieved from there. (I cannot use hashing) I am using static key and static salt for the time being.</p>
  
  <p>My question is how many iterations of salting should I do? I mean I have to store the value in the DB and I see that at 2 iterations (128bit key, 42bit salt) I get a encrypted string of 152 charaters for 40 characters. For 4 iterations, it's 364 characters for 40 characters, for 8 iterations 1536 characters for 40 characters and for 16 iterations, a ridiculous  19968 characters for 40 characters.</p>
  
  <p>So what should be my optimal number of iterations?</p>
  
  <pre><code> public static String AESencrypt(String value) throws Exception {
          Key key = generateKey();
          Cipher c = Cipher.getInstance(ALGORITHM);
          c.init(Cipher.ENCRYPT_MODE, key);
  
          String valueToEnc = null;
          String eValue = value;
          for (int i = 0; i &lt; ITERATIONS; i++) {
              valueToEnc = salt + eValue;
              byte[] encValue = c.doFinal(valueToEnc.getBytes());
              eValue = new BASE64Encoder().encode(encValue);
          }
          return eValue;
      }
  
      public static String AESdecrypt(String value) throws Exception {
          Key key = generateKey();
          Cipher c = Cipher.getInstance(ALGORITHM);
          c.init(Cipher.DECRYPT_MODE, key);
  
          String dValue = null;
          String valueToDecrypt = value;
          for (int i = 0; i &lt; ITERATIONS; i++) {
              byte[] decordedValue = new BASE64Decoder().decodeBuffer(valueToDecrypt);
              byte[] decValue = c.doFinal(decordedValue);
              dValue = new String(decValue).substring(salt.length());
              valueToDecrypt = dValue;
          }
          return dValue;
      }
  </code></pre>