title: Jasypt CLI error Operation not possible (Bad input or parameters)
body: <p>I'm running into an issue identical to <a href="https://stackoverflow.com/questions/20497292/command-line-jasypt-client-encryption-operation-not-possible">Command line Jasypt client encryption &#39;Operation not possible&#39;</a> however that post is for a much older version of Java.</p>
  
  <p>I've checked the path listed for java (in java_home below) and see the lib\security\policy\unlimited folder with the necessary .jar files but I still get the below error.</p>
  
  <p>While it may or may not be related I cannot get the arg ivGeneratorClassName=RandomIvGenerator to work either which is driving me almost equally nuts.  It throws a ClassNotFound exception but by George the class org.jasypt.iv.RandomIvGenerator is there when I expand it out in Eclipse.</p>
  
  <p>Jasypt output:</p>
  
  <pre><code>C:\jsypt\bin&gt;encrypt.bat input=SomeVeryLongPassword password=MixItUpALot algorit
  hm=PBEWITHHMACSHA256ANDAES_256
  
  ----ENVIRONMENT-----------------
  
  Runtime: Oracle Corporation Java HotSpot(TM) Client VM 25.171-b11
  
  
  
  ----ARGUMENTS-------------------
  
  algorithm: PBEWITHHMACSHA256ANDAES_256
  input: SomeVeryLongPassword
  password: MixItUpALot
  
  
  
  ----ERROR-----------------------
  
  Operation not possible (Bad input or parameters)
  </code></pre>
  
  <p>Algorythm list (formatted to be slightly more readable):</p>
  
  <pre><code>    C:\jsypt\bin&gt;listAlgorithms.bat
  
      DIGEST ALGORITHMS:   [MD2, MD5, SHA, SHA-224, SHA-256, SHA-384, SHA-512]
  
      PBE ALGORITHMS:      [PBEWITHHMACSHA1ANDAES_128, PBEWITHHMACSHA1ANDAES_256, PBEWITHHMACSHA224ANDAES_128, 
      PBEWITHHMACSHA224ANDAES_256, PBEWITHHMACSHA256ANDAES_128, PBEWITHHMACSHA256ANDAES_256, PBEWITHHMACSHA384ANDAES_128, 
  PBEWITHHMACSHA384ANDAES_256, PBEWITHHMACSHA512ANDAES_128, PBEWITHHMACSHA512ANDAES_256, PBEWITHMD5ANDDES,  
  PBEWITHMD5ANDTRIPLEDES, PBEWITHSHA1ANDDESEDE, PBEWITHSHA1ANDRC2_128, PBEWITHSHA1ANDRC2_40, PBEWITHSHA1ANDRC4_128,
  PBEWITHSHA1ANDRC4_40]
  </code></pre>
  
  <p>Java Version:</p>
  
  <pre><code>C:\jsypt\bin&gt;java -version
  java version "1.8.0_171"
  Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
  Java HotSpot(TM) Client VM (build 25.171-b11, mixed mode, sharing)
  </code></pre>
  
  <p>Java Home:</p>
  
  <pre><code>C:\jsypt\bin&gt;set JAVA_HOME
  JAVA_HOME=C:\Program Files (x86)\Java\jre1.8.0_171
  </code></pre>
  
  <p>A quick run of the program below yields: 2147483647 which indicates unlimited is enabled.  So I'm totally lost.</p>
  
  <pre><code>try {
  int maxKeyLen = Cipher.getMaxAllowedKeyLength("AES");
  System.out.println(maxKeyLen);
  } catch (Exception e) {
      System.out.println(e);
  }
  </code></pre>
  
  <p><strong><em>EDIT</em></strong>:  This appears to be related to the CLI is executing.  Threw together the below code from the sample usage (changing the algorithm) and it is able to generate the encrypted password.  The below is a <strong>work around</strong> for me but I would like to be able to do this from <strong>CLI</strong> as to not need to edit/compile/run this every 90 days when the password is supposed to be changed.</p>
  
  <pre><code>try {
           StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
           encryptor.setPassword("jasypt"); // could be got from web, env variable...
           encryptor.setAlgorithm("PBEWITHHMACSHA256ANDAES_256");
           encryptor.setIvGenerator(new RandomIvGenerator());
           String encrypted = encryptor.encrypt("ThisisaATest");
           System.out.println(encrypted);
  } catch (Exception e) {
      System.out.println(e);
  }
  </code></pre>