1 // Copyright 2017 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 #ifndef NET_BASE_HEX_UTILS_H_ 6 #define NET_BASE_HEX_UTILS_H_ 7 8 #include <string> 9 10 #include "base/strings/string_piece.h" 11 #include "net/base/net_export.h" 12 13 namespace net { 14 15 // Return a std::string containing hex and ASCII representations of the binary 16 // buffer |input|, with offsets at the beginning of each line, in the style of 17 // hexdump. Non-printable characters will be shown as '.' in the ASCII output. 18 // Example output: 19 // "0x0000: 0090 69bd 5400 000d 610f 0189 0800 4500 ..i.T...a.....E.\n" 20 // "0x0010: 001c fb98 4000 4001 7e18 d8ef 2301 455d ....@.@.~...#.E]\n" 21 // "0x0020: 7fe2 0800 6bcb 0bc6 806e ....k....n\n" 22 NET_EXPORT_PRIVATE std::string HexDump(base::StringPiece input); 23 24 } // namespace net 25 26 #endif // NET_BASE_HEX_UTILS_H_ 27