Class WebSocketUtil
java.lang.Object
io.netty.handler.codec.http.websocketx.WebSocketUtil
A utility class mainly for use by web sockets
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final FastThreadLocal
<MessageDigest> private static final FastThreadLocal
<MessageDigest> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
A private constructor to ensure that instances of this class cannot be made -
Method Summary
Modifier and TypeMethodDescription(package private) static String
base64
(byte[] data) Performs base64 encoding on the specified data(package private) static int
byteAtIndex
(int mask, int index) private static byte[]
digest
(FastThreadLocal<MessageDigest> digestFastThreadLocal, byte[] data) (package private) static byte[]
md5
(byte[] data) Performs a MD5 hash on the specified data(package private) static byte[]
randomBytes
(int size) Creates an arbitrary number of random bytes(package private) static int
randomNumber
(int minimum, int maximum) Generates a pseudo-random number(package private) static byte[]
sha1
(byte[] data) Performs a SHA-1 hash on the specified data
-
Field Details
-
MD5
-
SHA1
-
-
Constructor Details
-
WebSocketUtil
private WebSocketUtil()A private constructor to ensure that instances of this class cannot be made
-
-
Method Details
-
md5
static byte[] md5(byte[] data) Performs a MD5 hash on the specified data- Parameters:
data
- The data to hash- Returns:
- The hashed data
-
sha1
static byte[] sha1(byte[] data) Performs a SHA-1 hash on the specified data- Parameters:
data
- The data to hash- Returns:
- The hashed data
-
digest
-
base64
Performs base64 encoding on the specified data- Parameters:
data
- The data to encode- Returns:
- An encoded string containing the data
-
randomBytes
static byte[] randomBytes(int size) Creates an arbitrary number of random bytes- Parameters:
size
- the number of random bytes to create- Returns:
- An array of random bytes
-
randomNumber
static int randomNumber(int minimum, int maximum) Generates a pseudo-random number- Parameters:
minimum
- The minimum allowable valuemaximum
- The maximum allowable value- Returns:
- A pseudo-random number
-
byteAtIndex
static int byteAtIndex(int mask, int index)
-