Class WebSocketUtil

java.lang.Object
io.netty.handler.codec.http.websocketx.WebSocketUtil

final class WebSocketUtil extends Object
A utility class mainly for use by web sockets
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final FastThreadLocal<MessageDigest>
     
    private static final FastThreadLocal<MessageDigest>
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    A private constructor to ensure that instances of this class cannot be made
  • Method Summary

    Modifier and Type
    Method
    Description
    (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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • 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

      private static byte[] digest(FastThreadLocal<MessageDigest> digestFastThreadLocal, byte[] data)
    • base64

      static 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 value
      maximum - The maximum allowable value
      Returns:
      A pseudo-random number
    • byteAtIndex

      static int byteAtIndex(int mask, int index)