Module: Protocol::WebSocket::Headers::Nounce

Defined in:
lib/protocol/websocket/headers.rb

Overview

Provides utilities for generating and verifying the WebSocket handshake nonce.

Constant Summary collapse

GUID =
"258EAFA5-E914-47DA-95CA-C5AB0DC85B11"

Class Method Summary collapse

Class Method Details

.accept_digest(key) ⇒ Object

Valid for the ‘SEC_WEBSOCKET_ACCEPT` header.



37
38
39
# File 'lib/protocol/websocket/headers.rb', line 37

def self.accept_digest(key)
	Digest::SHA1.base64digest(key + GUID)
end

.generate_keyObject

Valid for the ‘SEC_WEBSOCKET_KEY` header.



32
33
34
# File 'lib/protocol/websocket/headers.rb', line 32

def self.generate_key
	SecureRandom.base64(16)
end