MCPcopy Create free account
hub / github.com/apache/impala / ToHex

Function ToHex

be/src/exprs/expr-test.cc:5857–5868  ·  view source on GitHub ↗

Convert character array `str` of length `len` to hexadecimal.

Source from the content-addressed store, hash-verified

5855
5856/// Convert character array `str` of length `len` to hexadecimal.
5857std::string ToHex(const unsigned char * str, int len) {
5858 stringstream ss;
5859 ss << hex << std::uppercase << setfill('0');
5860 for (int i = 0; i < len; ++i) {
5861 // setw is not sticky. stringstream only converts integral values,
5862 // so a cast to int is required, but only convert the least significant byte to hex.
5863 ss << setw(2) << (static_cast<int32_t>(str[i]) & 0xFF);
5864 }
5865 std::string result = ss.str();
5866 boost::to_lower(result);
5867 return result;
5868}
5869
5870TEST_P(ExprTest, SHAFunctions) {
5871 unsigned char input[] = "compute sha digest";

Callers 1

TEST_PFunction · 0.85

Calls 1

strMethod · 0.45

Tested by

no test coverage detected