xref: /aosp_15_r20/external/cronet/net/websockets/websocket_handshake_challenge.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2014 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "net/websockets/websocket_handshake_challenge.h"
6 
7 #include "base/base64.h"
8 #include "base/hash/sha1.h"
9 #include "net/websockets/websocket_handshake_constants.h"
10 
11 namespace net {
12 
ComputeSecWebSocketAccept(const std::string & key)13 std::string ComputeSecWebSocketAccept(const std::string& key) {
14   std::string hash = base::SHA1HashString(key + websockets::kWebSocketGuid);
15   return base::Base64Encode(hash);
16 }
17 
18 }  // namespace net
19