How to convert Byte Array to hex string in visual c++?

前端 未结 5 1183
野性不改
野性不改 2021-01-11 16:59

Declaration of a method are following:

//some.h
void TDES_Decryption(BYTE *Data, BYTE *Key, BYTE *InitalVector, int Length);

I am calling t

5条回答
  •  不知归路
    2021-01-11 17:54

    As you have mentioned c++, here is an answer. Iomanip is used to store ints in hex form into stringstream.

    #include 
    #include 
    
    std::string hexStr(BYTE *data, int len)
    {
         std::stringstream ss;
         ss << std::hex;
    
         for( int i(0) ; i < len; ++i )
             ss << std::setw(2) << std::setfill('0') << (int)data[i];
    
         return ss.str();
    }
    

提交回复
热议问题