Class WebSocketUtil
- java.lang.Object
-
- io.netty.handler.codec.http.websocketx.WebSocketUtil
-
final class WebSocketUtil extends java.lang.Object
A utility class mainly for use by web sockets
-
-
Field Summary
Fields Modifier and Type Field Description private static FastThreadLocal<java.security.MessageDigest>
MD5
private static FastThreadLocal<java.security.MessageDigest>
SHA1
-
Constructor Summary
Constructors Modifier Constructor Description private
WebSocketUtil()
A private constructor to ensure that instances of this class cannot be made
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static java.lang.String
base64(byte[] data)
Performs base64 encoding on the specified dataprivate static byte[]
digest(FastThreadLocal<java.security.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 Detail
-
MD5
private static final FastThreadLocal<java.security.MessageDigest> MD5
-
SHA1
private static final FastThreadLocal<java.security.MessageDigest> SHA1
-
-
Method Detail
-
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
private static byte[] digest(FastThreadLocal<java.security.MessageDigest> digestFastThreadLocal, byte[] data)
-
base64
static java.lang.String base64(byte[] data)
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
-
-