@Test public void testEncrypt() throws Exception { System.out.println("encrypt"); String str = "test"; DefaultCryptor instance = new DefaultCryptor(); String expResult = "test"; String result =instance.decrypt(instance.encrypt(str)); assertEquals(expResult, result); }
public String encrypt(String str) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, UnsupportedEncodingException { byte[] encs = crypt(Cipher.ENCRYPT_MODE, str.getBytes()); encs = Base64.encodeBase64(encs); return new String(encs, "UTF-8"); }
DefaultCryptor implements Cryptor { public String encrypt(String str) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, UnsupportedEncodingException { byte[] encs = crypt(Cipher.ENCRYPT_MODE, str.getBytes()); encs = Base64.encodeBase64(encs); return new String(encs, "UTF-8"); } }
DefaultCryptor implements Cryptor { public String encrypt(String str) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, UnsupportedEncodingException { byte[] encs = crypt(Cipher.ENCRYPT_MODE, str.getBytes()); encs = Base64.encodeBase64(encs); return new String(encs, "UTF-8"); } DefaultCryptor(); }
DefaultCryptor implements Cryptor { public String encrypt(String str) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, UnsupportedEncodingException { byte[] encs = crypt(Cipher.ENCRYPT_MODE, str.getBytes()); encs = Base64.encodeBase64(encs); return new String(encs, "UTF-8"); } DefaultCryptor(); String encrypt(String str); String decrypt(String str); @Override String newKey(); }
DefaultCryptor implements Cryptor { public String encrypt(String str) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, UnsupportedEncodingException { byte[] encs = crypt(Cipher.ENCRYPT_MODE, str.getBytes()); encs = Base64.encodeBase64(encs); return new String(encs, "UTF-8"); } DefaultCryptor(); String encrypt(String str); String decrypt(String str); @Override String newKey();  }