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 ; } }
Compute the Sec - WebSocket - Accept header value as per RFC 6455