### Question:
UnixCrypt { public static String crypt(final byte[] original) { return crypt(original, null); }  static String crypt(final byte[] original); static String crypt(final byte[] original, String salt); static String crypt(final String original); static String crypt(final String original, final String salt);  }### Answer:
@Test public void testUnixCryptStrings() { assertEquals("xxWAum7tHdIUw", Crypt.crypt("secret", "xx")); assertEquals("12UFlHxel6uMM", Crypt.crypt("", "12")); assertEquals("12FJgqDtVOg7Q", Crypt.crypt("secret", "12")); assertEquals("12FJgqDtVOg7Q", Crypt.crypt("secret", "12345678")); }
@Test public void testUnixCryptBytes() { assertEquals("12UFlHxel6uMM", Crypt.crypt(new byte[0], "12")); assertEquals("./287bds2PjVw", Crypt.crypt("t\u00e4st", "./")); assertEquals("./bLIFNqo9XKQ", Crypt.crypt("t\u00e4st".getBytes(Charsets.ISO_8859_1), "./")); assertEquals("./bLIFNqo9XKQ", Crypt.crypt(new byte[]{(byte) 0x74, (byte) 0xe4, (byte) 0x73, (byte) 0x74}, "./")); }
@Test public void testUnixCryptExplicitCall() { assertTrue(UnixCrypt.crypt("secret".getBytes()).matches("^[a-zA-Z0-9./]{13}$")); assertTrue(UnixCrypt.crypt("secret".getBytes(), null).matches("^[a-zA-Z0-9./]{13}$")); }
@Test(expected = IllegalArgumentException.class) public void testUnixCryptWithHalfSalt() { UnixCrypt.crypt("secret", "x"); }
@Test(expected = IllegalArgumentException.class) public void testUnicCryptInvalidSalt() { UnixCrypt.crypt("secret", "$a"); }
@Test(expected = NullPointerException.class) public void testUnixCryptNullData() { UnixCrypt.crypt((byte[]) null); }
@Test(expected = IllegalArgumentException.class) public void testUnixCryptWithEmptySalt() { UnixCrypt.crypt("secret", ""); }
@Test public void testUnixCryptWithoutSalt() { final String hash = UnixCrypt.crypt("foo"); assertTrue(hash.matches("^[a-zA-Z0-9./]{13}$")); final String hash2 = UnixCrypt.crypt("foo"); assertNotSame(hash, hash2); }