Chromium Code Reviews| Index: media/cast/test/crypto_utility.cc |
| diff --git a/media/cast/test/crypto_utility.cc b/media/cast/test/crypto_utility.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9063af4c688ce18d179bbd931b5ca4173018c519 |
| --- /dev/null |
| +++ b/media/cast/test/crypto_utility.cc |
| @@ -0,0 +1,42 @@ |
| +// Copyright 2013 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 "media/cast/test/crypto_utility.h" |
| + |
| +namespace { |
| + |
| +char ConvertFromBase16Char(char base_16) { |
| + DCHECK((base_16 >= '0' && base_16 <= '9') || |
| + (base_16 >= 'a' && base_16 <= 'f') || |
| + (base_16 >= 'A' && base_16 <= 'F')); |
| + |
| + if (base_16 >= '0' && base_16 <= '9') { |
| + return base_16 - '0'; |
| + } |
| + if (base_16 >= 'a' && base_16 <= 'f') { |
| + return base_16 - 'a' + 10; |
| + } |
| + return base_16 - 'A' + 10; |
| +} |
| +} // namespace |
|
wtc
2013/11/13 20:57:17
Nit: add a blank line before this line. (This is p
pwestin
2013/11/15 19:38:17
removed this code
|
| + |
| +namespace media { |
| +namespace cast { |
| + |
| +std::string ConvertFromBase16String(const std::string base_16) { |
| + std::string compressed; |
| + DCHECK(base_16.size() % 2 == 0) << "Must be a multiple of 2"; |
| + compressed.reserve(base_16.size() / 2); |
| + |
| + for (std::string::const_iterator it = base_16.begin(); it != base_16.end(); |
| + ++it) { |
| + char first_part = ConvertFromBase16Char(*it++); |
| + char second_part = ConvertFromBase16Char(*it); |
| + compressed.push_back((first_part << 4) + second_part); |
| + } |
| + return compressed; |
| +} |
| + |
| +} // namespace cast |
| +} // namespace media |