@Test public void decrypt() throws Exception { String string0 = EncryptUtil.decrypt(KEY, SAMPLE1_ENC); Assert.assertEquals(SAMPLE1, string0); string0 = EncryptUtil.decrypt(KEY, SAMPLE2_ENC); Assert.assertEquals(SAMPLE2, string0); string0 = EncryptUtil.decrypt(KEY, SAMPLE3_ENC); Assert.assertEquals(SAMPLE3, string0); }
public static String decrypt(String key, String source) { try { Key key0 = getKey(key); Cipher desCipher = Cipher.getInstance("DES/ECB/PKCS5Padding"); byte[] ciphertext = Base64Codec.decode(source); desCipher.init(Cipher.DECRYPT_MODE, key0); byte[] cleartext = desCipher.doFinal(ciphertext); return new String(cleartext); } catch (Exception e) { throw new RuntimeException(e.getMessage()); } }
EncryptUtil { public static String decrypt(String key, String source) { try { Key key0 = getKey(key); Cipher desCipher = Cipher.getInstance("DES/ECB/PKCS5Padding"); byte[] ciphertext = Base64Codec.decode(source); desCipher.init(Cipher.DECRYPT_MODE, key0); byte[] cleartext = desCipher.doFinal(ciphertext); return new String(cleartext); } catch (Exception e) { throw new RuntimeException(e.getMessage()); } } }
EncryptUtil { public static String decrypt(String key, String source) { try { Key key0 = getKey(key); Cipher desCipher = Cipher.getInstance("DES/ECB/PKCS5Padding"); byte[] ciphertext = Base64Codec.decode(source); desCipher.init(Cipher.DECRYPT_MODE, key0); byte[] cleartext = desCipher.doFinal(ciphertext); return new String(cleartext); } catch (Exception e) { throw new RuntimeException(e.getMessage()); } }  }
EncryptUtil { public static String decrypt(String key, String source) { try { Key key0 = getKey(key); Cipher desCipher = Cipher.getInstance("DES/ECB/PKCS5Padding"); byte[] ciphertext = Base64Codec.decode(source); desCipher.init(Cipher.DECRYPT_MODE, key0); byte[] cleartext = desCipher.doFinal(ciphertext); return new String(cleartext); } catch (Exception e) { throw new RuntimeException(e.getMessage()); } }  static String generateKey(); static String encrypt(String key, String source); static String decrypt(String key, String source); }
EncryptUtil { public static String decrypt(String key, String source) { try { Key key0 = getKey(key); Cipher desCipher = Cipher.getInstance("DES/ECB/PKCS5Padding"); byte[] ciphertext = Base64Codec.decode(source); desCipher.init(Cipher.DECRYPT_MODE, key0); byte[] cleartext = desCipher.doFinal(ciphertext); return new String(cleartext); } catch (Exception e) { throw new RuntimeException(e.getMessage()); } }  static String generateKey(); static String encrypt(String key, String source); static String decrypt(String key, String source);  }