Last active
November 16, 2015 15:56
-
-
Save simlegate/5a36407963168a2d88b0 to your computer and use it in GitHub Desktop.
Revisions
-
simlegate revised this gist
Nov 16, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -26,6 +26,7 @@ # Digest::SHA1.base64digest(sec_websoekct_key + token) # NOTICE!! hexdigest is invalid. encrypted = Digest::SHA1.digest(sec_websoekct_key + token) sec_websokect_accept = Base64.encode64(encrypted).strip -
simlegate created this gist
Nov 16, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ require 'digest/sha1' require 'base64' # client request # GET / HTTP/1.1 # Upgrade: websocket # Connection: Upgrade # Host: example.com # Origin: null # Sec-WebSocket-Key: sN9cRrP/n9NdMgdcy2VJFQ== # Sec-WebSocket-Version: 13 # server response # HTTP/1.1 101 Switching Protocols # Upgrade: websocket # Connection: Upgrade # Sec-WebSocket-Accept: fFBooB7FAkLlXgRSz0BT3v4hq5s= # Sec-WebSocket-Origin: null # Sec-WebSocket-Location: ws://example.com/ sec_websoekct_key = 'sN9cRrP/n9NdMgdcy2VJFQ==' p "sec_websoekct_key is #{sec_websoekct_key}" token = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11' # Digest::SHA1.base64digest(sec_websoekct_key + token) encrypted = Digest::SHA1.digest(sec_websoekct_key + token) sec_websokect_accept = Base64.encode64(encrypted).strip p "generated sec_websokect_accept is #{sec_websokect_accept}"