Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 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 | |
| 5 #include "media/cast/test/crypto_utility.h" | |
| 6 | |
| 7 namespace { | |
| 8 | |
| 9 char ConvertFromBase16Char(char base_16) { | |
| 10 DCHECK((base_16 >= '0' && base_16 <= '9') || | |
| 11 (base_16 >= 'a' && base_16 <= 'f') || | |
| 12 (base_16 >= 'A' && base_16 <= 'F')); | |
| 13 | |
| 14 if (base_16 >= '0' && base_16 <= '9') { | |
| 15 return base_16 - '0'; | |
| 16 } | |
| 17 if (base_16 >= 'a' && base_16 <= 'f') { | |
| 18 return base_16 - 'a' + 10; | |
| 19 } | |
| 20 return base_16 - 'A' + 10; | |
| 21 } | |
| 22 } // 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
| |
| 23 | |
| 24 namespace media { | |
| 25 namespace cast { | |
| 26 | |
| 27 std::string ConvertFromBase16String(const std::string base_16) { | |
| 28 std::string compressed; | |
| 29 DCHECK(base_16.size() % 2 == 0) << "Must be a multiple of 2"; | |
| 30 compressed.reserve(base_16.size() / 2); | |
| 31 | |
| 32 for (std::string::const_iterator it = base_16.begin(); it != base_16.end(); | |
| 33 ++it) { | |
| 34 char first_part = ConvertFromBase16Char(*it++); | |
| 35 char second_part = ConvertFromBase16Char(*it); | |
| 36 compressed.push_back((first_part << 4) + second_part); | |
| 37 } | |
| 38 return compressed; | |
| 39 } | |
| 40 | |
| 41 } // namespace cast | |
| 42 } // namespace media | |
| OLD | NEW |