13
13
*/
14
14
package org .asynchttpclient .ws ;
15
15
16
+ import static java .nio .charset .StandardCharsets .US_ASCII ;
17
+
16
18
import java .io .UnsupportedEncodingException ;
17
19
import java .security .MessageDigest ;
18
20
import java .security .NoSuchAlgorithmException ;
@@ -24,13 +26,13 @@ public final class WebSocketUtils {
24
26
25
27
public static String getKey () {
26
28
byte [] nonce = createRandomBytes (16 );
27
- return base64Encode (nonce );
29
+ return Base64 . encode (nonce );
28
30
}
29
31
30
32
public static String getAcceptKey (String key ) throws UnsupportedEncodingException {
31
33
String acceptSeed = key + MAGIC_GUID ;
32
- byte [] sha1 = sha1 (acceptSeed .getBytes ("US-ASCII" ));
33
- return base64Encode (sha1 );
34
+ byte [] sha1 = sha1 (acceptSeed .getBytes (US_ASCII ));
35
+ return Base64 . encode (sha1 );
34
36
}
35
37
36
38
public static byte [] md5 (byte [] bytes ) {
@@ -51,10 +53,6 @@ public static byte[] sha1(byte[] bytes) {
51
53
}
52
54
}
53
55
54
- public static String base64Encode (byte [] bytes ) {
55
- return Base64 .encode (bytes );
56
- }
57
-
58
56
public static byte [] createRandomBytes (int size ) {
59
57
byte [] bytes = new byte [size ];
60
58
@@ -70,4 +68,3 @@ public static int createRandomNumber(int min, int max) {
70
68
}
71
69
72
70
}
73
-
0 commit comments