code: public static String acceptHash(String key) {
          try {
              MessageDigest sha1 = MessageDigest.getInstance("SHA-1");
              sha1.update(key.getBytes(UTF_8));
              sha1.update(WEBSOCKET_GUID);
              byte[] hash = sha1.digest();
              byte[] output = Base64.encodeBase64(hash);
              return new String(output);
          } catch (NoSuchAlgorithmException nsae) {
              SecurityException se = new SecurityException();
              se.initCause(nsae);
              throw se;
          }
      }
docs: Compute the Sec-WebSocket-Accept header value as per RFC 6455
  
  @param key Sec-WebSocket-Key header value
  @return the expected value for Sec-WebSocket-Accept header value