blob: 9ee0f091512f3d7b836bdedf826b7b797457c69f [file] [log] [blame]
// Copyright 2017 The Chromium OS 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 "login_manager/blob_util.h"
#include <base/logging.h>
#include <google/protobuf/message_lite.h>
namespace login_manager {
std::vector<uint8_t> SerializeAsBlob(
const google::protobuf::MessageLite& message) {
std::vector<uint8_t> result;
CHECK(message.SerializeToArray(, result.size()))
<< "Failed to serialize protobuf.";
return result;
std::vector<uint8_t> StringToBlob(base::StringPiece str) {
return std::vector<uint8_t>(str.begin(), str.end());
std::string BlobToString(const std::vector<uint8_t>& blob) {
return std::string(reinterpret_cast<const char*>(, blob.size());
} // namespace login_manager