websocket_handshake_challenge.cc 594 B

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