Skip to content

Commit a3a31a1

Browse files
committed
Javadoc.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/codec/trunk@1379810 13f79535-47bb-0310-9956-ffa450edef68
1 parent 08f16c1 commit a3a31a1

1 file changed

Lines changed: 25 additions & 22 deletions

File tree

src/main/java/org/apache/commons/codec/digest/Md5Crypt.java

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,15 @@
2626
/**
2727
* The libc crypt() "$1$" and Apache "$apr1$" MD5-based hash algorithm.
2828
* <p>
29-
* Based on the public domain ("beer-ware") C implementation from Poul-Henning Kamp which was found at:
30-
* <a href="http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libcrypt/crypt-md5.c?rev=1.1;content-type=text%2Fplain">
29+
* Based on the public domain ("beer-ware") C implementation from Poul-Henning Kamp which was found at: <a
30+
* href="http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libcrypt/crypt-md5.c?rev=1.1;content-type=text%2Fplain">
3131
* crypt-md5.c @ freebsd.org</a><br/>
3232
* <p>
3333
* Source:
34-
* <pre>$FreeBSD: src/lib/libcrypt/crypt-md5.c,v 1.1 1999/01/21 13:50:09 brandon Exp $</pre>
34+
*
35+
* <pre>
36+
* $FreeBSD: src/lib/libcrypt/crypt-md5.c,v 1.1 1999/01/21 13:50:09 brandon Exp $
37+
* </pre>
3538
* <p>
3639
* Conversion to Kotlin and from there to Java in 2012.
3740
* <p>
@@ -60,7 +63,7 @@ public class Md5Crypt {
6063
* See {@link #apr1Crypt(String, String)} for details.
6164
*
6265
* @throws RuntimeException
63-
* when a {@link java.security.NoSuchAlgorithmException} is caught. *
66+
* when a {@link java.security.NoSuchAlgorithmException} is caught. *
6467
*/
6568
public static String apr1Crypt(byte[] keyBytes) {
6669
return apr1Crypt(keyBytes, APR1_PREFIX + B64.getRandomSalt(8));
@@ -69,9 +72,10 @@ public static String apr1Crypt(byte[] keyBytes) {
6972
/**
7073
* See {@link #apr1Crypt(String, String)} for details.
7174
*
72-
* @throws IllegalArgumentException if the salt does not match the allowed pattern
75+
* @throws IllegalArgumentException
76+
* if the salt does not match the allowed pattern
7377
* @throws RuntimeException
74-
* when a {@link java.security.NoSuchAlgorithmException} is caught.
78+
* when a {@link java.security.NoSuchAlgorithmException} is caught.
7579
*/
7680
public static String apr1Crypt(byte[] keyBytes, String salt) {
7781
// to make the md5Crypt regex happy
@@ -85,7 +89,7 @@ public static String apr1Crypt(byte[] keyBytes, String salt) {
8589
* See {@link #apr1Crypt(String, String)} for details.
8690
*
8791
* @throws RuntimeException
88-
* when a {@link java.security.NoSuchAlgorithmException} is caught.
92+
* when a {@link java.security.NoSuchAlgorithmException} is caught.
8993
*/
9094
public static String apr1Crypt(String keyBytes) {
9195
return apr1Crypt(keyBytes.getBytes(Charsets.UTF_8));
@@ -94,19 +98,19 @@ public static String apr1Crypt(String keyBytes) {
9498
/**
9599
* Generates an Apache htpasswd compatible "$apr1$" MD5 based hash value.
96100
* <p>
97-
* The algorithm is identical to the crypt(3) "$1$" one but produces different
98-
* outputs due to the different salt prefix.
101+
* The algorithm is identical to the crypt(3) "$1$" one but produces different outputs due to the different salt
102+
* prefix.
99103
*
100104
* @param keyBytes
101105
* plaintext string that should be hashed.
102106
* @param salt
103-
* salt string including the prefix and optionally garbage at the end.
104-
* Will be generated randomly if null.
107+
* salt string including the prefix and optionally garbage at the end. Will be generated randomly if
108+
* null.
105109
* @return computed hash value
106110
* @throws IllegalArgumentException
107-
* if the salt does not match the allowed pattern
111+
* if the salt does not match the allowed pattern
108112
* @throws RuntimeException
109-
* when a {@link java.security.NoSuchAlgorithmException} is caught.
113+
* when a {@link java.security.NoSuchAlgorithmException} is caught.
110114
*/
111115
public static String apr1Crypt(String keyBytes, String salt) {
112116
return apr1Crypt(keyBytes.getBytes(Charsets.UTF_8), salt);
@@ -118,7 +122,7 @@ public static String apr1Crypt(String keyBytes, String salt) {
118122
* See {@link Crypt#crypt(String, String)} for details.
119123
*
120124
* @throws RuntimeException
121-
* when a {@link java.security.NoSuchAlgorithmException} is caught.
125+
* when a {@link java.security.NoSuchAlgorithmException} is caught.
122126
*/
123127
public static String md5Crypt(final byte[] keyBytes) {
124128
return md5Crypt(keyBytes, MD5_PREFIX + B64.getRandomSalt(8));
@@ -132,13 +136,13 @@ public static String md5Crypt(final byte[] keyBytes) {
132136
* @param keyBytes
133137
* plaintext string that should be hashed.
134138
* @param salt
135-
* salt string including the prefix and optionally garbage at the end.
136-
* Will be generated randomly if null.
139+
* salt string including the prefix and optionally garbage at the end. Will be generated randomly if
140+
* null.
137141
* @return computed hash value
138142
* @throws IllegalArgumentException
139-
* if the salt does not match the allowed pattern
143+
* if the salt does not match the allowed pattern
140144
* @throws RuntimeException
141-
* when a {@link java.security.NoSuchAlgorithmException} is caught.
145+
* when a {@link java.security.NoSuchAlgorithmException} is caught.
142146
*/
143147
public static String md5Crypt(byte[] keyBytes, String salt) {
144148
return md5Crypt(keyBytes, salt, MD5_PREFIX);
@@ -150,12 +154,11 @@ public static String md5Crypt(byte[] keyBytes, String salt) {
150154
* See {@link Crypt#crypt(String, String)} or {@link #apr1Crypt(String, String)} for details.
151155
*
152156
* @throws IllegalArgumentException
153-
* if the salt does not match the allowed pattern
157+
* if the salt does not match the allowed pattern
154158
* @throws RuntimeException
155-
* when a {@link java.security.NoSuchAlgorithmException} is caught.
159+
* when a {@link java.security.NoSuchAlgorithmException} is caught.
156160
*/
157-
public static String md5Crypt(final byte[] keyBytes, final String salt, final String prefix)
158-
{
161+
public static String md5Crypt(final byte[] keyBytes, final String salt, final String prefix) {
159162
int keyLen = keyBytes.length;
160163

161164
// Extract the real salt from the given string which can be a complete hash string.

0 commit comments

Comments
 (0)