### Question:
Encryptor { public static String encrypt(String value) { try { MessageDigest digest = MessageDigest.getInstance(DA_MD5); byte[] hash = digest.digest(value.getBytes(def_encoding)); StringBuilder hexString = new StringBuilder(2*hash.length); for (byte b: hash) { hexString.append(String.format("%02x", b&0xff)); } return hexString.toString(); } catch (NoSuchAlgorithmException e) { return null; } catch (UnsupportedEncodingException e) { return null; } }  static String encrypt(String value); static String encrypt(String value, String salt);  }### Answer:
@Test public void testEncrypt() { String password = "password"; String pwd1 = Encryptor.encrypt(password); String pwd2 = Encryptor.encrypt(password); assertEquals(pwd1, pwd2); String salt = "12345"; pwd1 = Encryptor.encrypt(password, salt); pwd2 = Encryptor.encrypt(password, salt); assertEquals(pwd1, pwd2); }
@Test @Ignore public void testCipher() { CipherEncryptor ce = new CipherEncryptor("AES", "testtesttesttest"); String password = "password"; String pwd1 = ce.encrypt(password); String pwd2 = ce.decrypt(pwd1); assertEquals(password, pwd2); }
@Test @Ignore public void testCipher2() throws Exception { String password = "password"; String nonce = "testtesttesttest"; String pwd1 = CipherEncryptor.encrypt(password, nonce); String pwd2 = CipherEncryptor.encrypt(password, nonce); assertEquals(password, CipherEncryptor.decrypt(pwd1, nonce)); assertEquals(password, CipherEncryptor.decrypt(pwd2, nonce)); }