code: public static String encrypt(String input, String strkey)
      throws GeneralSecurityException {
          SecretKey key;
          if (strkey != null) {
              if (strkey.length() > 56)
                  strkey = strkey.substring(0, 55);
              key = new SecretKeySpec(strkey.getBytes(), algorithm);
          }
          else {
              if (defaultKey==null) defaultKey =
                  new SecretKeySpec(defaultKeyString.getBytes(), algorithm);
              key = defaultKey;
          }
          Cipher cipher = Cipher.getInstance(algorithm);
          cipher.init(Cipher.ENCRYPT_MODE, key);
          byte[] inputBytes = input.getBytes();
          byte[] encrypted = cipher.doFinal(inputBytes);
          return encodeAlpha(encrypted);
      }
docs: Encrypt a string
  @param input data to encrypt
  @param strkey a default key will be used when passing null in
  @return encrypted string