@@ -33,14 +33,14 @@ public class Crypt {
3333 /**
3434 * Encrypts a password in a crypt(3) compatible way.
3535 * <p>
36- * A random salt and the default algorithm (currently SHA-512) are used. See
37- * {@link #crypt(String, String)} for details.
36+ * A random salt and the default algorithm (currently SHA-512) are used. See {@link #crypt(String, String)} for
37+ * details.
3838 *
3939 * @param keyBytes
4040 * plaintext password
4141 * @return hash value
4242 * @throws RuntimeException
43- * when a {@link java.security.NoSuchAlgorithmException} is caught.
43+ * when a {@link java.security.NoSuchAlgorithmException} is caught.
4444 */
4545 public static String crypt (byte [] keyBytes ) {
4646 return crypt (keyBytes , null );
@@ -49,18 +49,18 @@ public static String crypt(byte[] keyBytes) {
4949 /**
5050 * Encrypts a password in a crypt(3) compatible way.
5151 * <p>
52- * If no salt is provided, a random salt and the default algorithm (currently SHA-512) will be used.
53- * See {@link #crypt(String, String)} for details.
52+ * If no salt is provided, a random salt and the default algorithm (currently SHA-512) will be used. See
53+ * {@link #crypt(String, String)} for details.
5454 *
5555 * @param keyBytes
5656 * plaintext password
5757 * @param salt
5858 * salt value
5959 * @return hash value
6060 * @throws IllegalArgumentException
61- * if the salt does not match the allowed pattern
61+ * if the salt does not match the allowed pattern
6262 * @throws RuntimeException
63- * when a {@link java.security.NoSuchAlgorithmException} is caught.
63+ * when a {@link java.security.NoSuchAlgorithmException} is caught.
6464 */
6565 public static String crypt (byte [] keyBytes , String salt ) {
6666 if (salt == null ) {
@@ -86,7 +86,7 @@ public static String crypt(byte[] keyBytes, String salt) {
8686 * plaintext password
8787 * @return hash value
8888 * @throws RuntimeException
89- * when a {@link java.security.NoSuchAlgorithmException} is caught.
89+ * when a {@link java.security.NoSuchAlgorithmException} is caught.
9090 */
9191 public static String crypt (String key ) {
9292 return crypt (key , null );
@@ -103,19 +103,20 @@ public static String crypt(String key) {
103103 * <li>DES, the traditional UnixCrypt algorithm is used else with only 2 chars
104104 * <li>Only the first 8 chars of the passwords are used in the DES algorithm!
105105 * </ul>
106- * The magic strings "$apr1$" and "$2a$" are not recognised by this method as its
107- * output should be identical with that of the libc implementation.
106+ * The magic strings "$apr1$" and "$2a$" are not recognised by this method as its output should be identical with
107+ * that of the libc implementation.
108108 * <p>
109- * The rest of the salt string is drawn from the set [a-zA-Z0-9./] and is cut at the
110- * maximum length of if a "$" sign is encountered. It is therefore valid to enter a
111- * complete hash value as salt to e.g. verify a password with:
109+ * The rest of the salt string is drawn from the set [a-zA-Z0-9./] and is cut at the maximum length of if a "$"
110+ * sign is encountered. It is therefore valid to enter a complete hash value as salt to e.g. verify a password
111+ * with:
112+ *
112113 * <pre>
113- * storedPwd.equals(crypt(enteredPwd, storedPwd))
114+ * storedPwd.equals(crypt(enteredPwd, storedPwd))
114115 * </pre>
115116 * <p>
116- * The resulting string starts with the marker string ($6$), continues with the salt
117- * value and ends with a "$" sign followed by the actual hash value. For DES the string
118- * only contains the salt and actual hash. It's total length is dependent on the algorithm used:
117+ * The resulting string starts with the marker string ($6$), continues with the salt value and ends with a "$" sign
118+ * followed by the actual hash value. For DES the string only contains the salt and actual hash. It's total length
119+ * is dependent on the algorithm used:
119120 * <ul>
120121 * <li>SHA-512: 106 chars
121122 * <li>SHA-256: 63 chars
@@ -124,13 +125,14 @@ public static String crypt(String key) {
124125 * </ul>
125126 * <p>
126127 * Example:
128+ *
127129 * <pre>
128130 * crypt("secret", "$1$xxxx") => "$1$xxxx$aMkevjfEIpa35Bh3G4bAc."
129131 * crypt("secret", "xx") => "xxWAum7tHdIUw"
130132 * </pre>
131133 * <p>
132- * This method comes in a variation that accepts a byte[] array to support input strings that
133- * are not encoded in UTF-8 but e.g. in ISO-8859-1 where equal characters result in different byte values.
134+ * This method comes in a variation that accepts a byte[] array to support input strings that are not encoded in
135+ * UTF-8 but e.g. in ISO-8859-1 where equal characters result in different byte values.
134136 *
135137 * @see "The man page of the libc crypt (3) function."
136138 * @param key
@@ -139,9 +141,9 @@ public static String crypt(String key) {
139141 * salt value
140142 * @return hash value, i.e. encrypted password including the salt string
141143 * @throws IllegalArgumentException
142- * if the salt does not match the allowed pattern
144+ * if the salt does not match the allowed pattern
143145 * @throws RuntimeException
144- * when a {@link java.security.NoSuchAlgorithmException} is caught. *
146+ * when a {@link java.security.NoSuchAlgorithmException} is caught. *
145147 */
146148 public static String crypt (String key , String salt ) {
147149 return crypt (key .getBytes (Charsets .UTF_8 ), salt );
0 commit comments