summaryrefslogtreecommitdiffstats
path: root/net/websockets/websocket_handshake_challenge.cc
blob: 3a1c3e8adec8e2aaa2379ab206ce8de893ee90ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "net/websockets/websocket_handshake_challenge.h"

#include "base/base64.h"
#include "base/sha1.h"
#include "net/websockets/websocket_handshake_constants.h"

namespace net {

std::string ComputeSecWebSocketAccept(const std::string& key) {
  std::string accept;
  std::string hash = base::SHA1HashString(key + websockets::kWebSocketGuid);
  base::Base64Encode(hash, &accept);
  return accept;
}

}  // namespace net