INNER CODE UNIT · Ruby
close
royshil/obs-backgroundremoval · scripts/ws_client.rb:94
def close
@socket.close if @socket
end
def authenticate(password)
hello = JSON.parse(receive_packet)
if hello && hello['op'] == 0
salt = hello['d']['authentication']['salt']
challenge = hello['d']['authentication']['challenge']
secret = Base64.strict_encode64(Digest::SHA256.digest(password + salt))
auth_response = Base64.strict_encode64(Digest::SHA256.digest(secret + challenge))
send_packet({
"op" => 1,
"d" => { "rpcVersion" => 1, "authentication" => auth_response, "eventSubscriptions" => 0 }
})
end