@Test public void EncryptedFormat() throws Exception { int failed = 0; for (int i = 0; i < ENCRYPTED_NAMES.length; i++) { String encrypted = ENCRYPTED_NAMES[i]; try { String decrypted = CryptoUtil.decrypt(encrypted); if (!UNICODE_NAMES[i].equals(decrypted)) { LOGGER.error(String.format("String changed during decryption. Original: %s, New: %s", UNICODE_NAMES[i], decrypted)); failed++; } } catch (DecryptException e) { LOGGER.error(String.format("Decryption Failed For '%s': %s", encrypted, e.getMessage()), e); failed++; } } assertEquals(String.format("%d Failures", failed), 0, failed); }
public static String decrypt(String encrypted) throws DecryptException { String s = null; if (encrypted != null) { byte[] b = decryptAES(MossoConfig.getCryptoKeySpec(), CryptoUtilValues.TRANSFORMATION_MODE_ECB, CryptoUtilValues.TRANSFORMATION_PADDING_NO_PADDING, CryptoUtil.asBytes(encrypted, CryptoUtilValues.CRYPTO_PAD_BYTE)); try { s = new String(b, ENCODING); } catch (UnsupportedEncodingException ex) { s = new String(b); } if (s != null) { s = s.trim(); } } return s; }
CryptoUtil { public static String decrypt(String encrypted) throws DecryptException { String s = null; if (encrypted != null) { byte[] b = decryptAES(MossoConfig.getCryptoKeySpec(), CryptoUtilValues.TRANSFORMATION_MODE_ECB, CryptoUtilValues.TRANSFORMATION_PADDING_NO_PADDING, CryptoUtil.asBytes(encrypted, CryptoUtilValues.CRYPTO_PAD_BYTE)); try { s = new String(b, ENCODING); } catch (UnsupportedEncodingException ex) { s = new String(b); } if (s != null) { s = s.trim(); } } return s; } }
CryptoUtil { public static String decrypt(String encrypted) throws DecryptException { String s = null; if (encrypted != null) { byte[] b = decryptAES(MossoConfig.getCryptoKeySpec(), CryptoUtilValues.TRANSFORMATION_MODE_ECB, CryptoUtilValues.TRANSFORMATION_PADDING_NO_PADDING, CryptoUtil.asBytes(encrypted, CryptoUtilValues.CRYPTO_PAD_BYTE)); try { s = new String(b, ENCODING); } catch (UnsupportedEncodingException ex) { s = new String(b); } if (s != null) { s = s.trim(); } } return s; } private  CryptoUtil(); }
CryptoUtil { public static String decrypt(String encrypted) throws DecryptException { String s = null; if (encrypted != null) { byte[] b = decryptAES(MossoConfig.getCryptoKeySpec(), CryptoUtilValues.TRANSFORMATION_MODE_ECB, CryptoUtilValues.TRANSFORMATION_PADDING_NO_PADDING, CryptoUtil.asBytes(encrypted, CryptoUtilValues.CRYPTO_PAD_BYTE)); try { s = new String(b, ENCODING); } catch (UnsupportedEncodingException ex) { s = new String(b); } if (s != null) { s = s.trim(); } } return s; } private  CryptoUtil(); static String decrypt(String encrypted); static String encrypt(String decrypted); static int getMaxKeySize(); }
CryptoUtil { public static String decrypt(String encrypted) throws DecryptException { String s = null; if (encrypted != null) { byte[] b = decryptAES(MossoConfig.getCryptoKeySpec(), CryptoUtilValues.TRANSFORMATION_MODE_ECB, CryptoUtilValues.TRANSFORMATION_PADDING_NO_PADDING, CryptoUtil.asBytes(encrypted, CryptoUtilValues.CRYPTO_PAD_BYTE)); try { s = new String(b, ENCODING); } catch (UnsupportedEncodingException ex) { s = new String(b); } if (s != null) { s = s.trim(); } } return s; } private  CryptoUtil(); static String decrypt(String encrypted); static String encrypt(String decrypted); static int getMaxKeySize(); static final String ENCODING; }