title: How to decrypt Triple Des CryptoJS values in Java class
body: <p>I was asked to encrypt some text from client side ( web ) before sending it to server side ( java )</p>
  
  <p>So i try to use CryptoJS library for client side.
  I encrypt it like this :</p>
  
  <pre><code>    var key = "aaaaaaaaaaaaaaaaaaaaaaaa";
      var value = "KF169841";
      var encryptedString = CryptoJS.TripleDES.encrypt(value, key);
      console.log(encryptedString.toString());
  </code></pre>
  
  <p>And i get something like this : U2FsdGVkX19eYFFHgYGCr3v9/skTOKVp0pLWRNK9JTg=
  I use this encryptedString and key in other <a href="http://myeasywww.appspot.com/easyweb?command=UTILITY&amp;ID=2" rel="nofollow">Decrypt tool online</a> ( Which also use CryptoJS ) and got back exact value KF169841.</p>
  
  <p>After sending this value and key to server ( well key isn't sending directly to server though but for test, it is ), i need to decrypt it using Java.
  But i quite don't know how to decrypt it. I'm tried some code from google search but it end up wrong padding if use DESese or get wrong value if i use ECB/NoPadding. 
  I did try to something like setting sfg for CryptoJS side like:</p>
  
  <pre><code>    mode: CryptoJS.mode.EBC,
      padding: CryptoJS.pad.NoPadding
  </code></pre>
  
  <p>But they got javascript exception ( a is not define )</p>
  
  <p>So any have any experience with CryptoJS can help me decrypt this one using java ?</p>
  
  <p>=============================================================</p>
  
  <p>UPDATE : Sorry here my server side code i'm using</p>
  
  <pre><code>/**
       * Method To Decrypt An Ecrypted String
       */
      public String decrypt(String encryptedString, String myEncryptionKey) {
          String decryptedText = null;
          try {
              byte[] keyAsBytes = myEncryptionKey.getBytes("UTF8");
              KeySpec myKeySpec = new DESedeKeySpec(keyAsBytes);
              SecretKeyFactory mySecretKeyFactory = 
                      SecretKeyFactory.getInstance("DESede");
              Cipher cipher = Cipher.getInstance("DESede/ECB/NoPadding");
              SecretKey key = mySecretKeyFactory.generateSecret(myKeySpec);
  
              cipher.init(Cipher.DECRYPT_MODE, key);
  //            BASE64Decoder base64decoder = new BASE64Decoder();
  //            byte[] encryptedText = base64decoder.decodeBuffer(encryptedString);
  
              byte[] encryptedText =  org.apache.commons.codec.binary.Base64.decodeBase64(encryptedString);
              byte[] plainText = cipher.doFinal(encryptedText);
              decryptedText= bytes2String(plainText);
          } catch (Exception e) {
              e.printStackTrace();
          }
          return decryptedText;
      }
  </code></pre>