fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. vector<uint8_t> HexToBytes(const string& hex) {
  7. vector<uint8_t> bytes;
  8. for (unsigned int i = 0; i < hex.length(); i += 2) {
  9. string byteString = hex.substr(i, 2);
  10. uint8_t byte = (uint8_t) strtol(byteString.c_str(), nullptr, 16);
  11. bytes.push_back(byte);
  12. }
  13. return bytes;
  14. }
  15.  
  16. int main() {
  17. vector<uint8_t> h = HexToBytes("0b7c28c9b7290c98d7438e70b3d3f7c848fbd7d1dc194ff83f4f7cc9b1378e98");
  18. for (auto c : h) {
  19. cout << hex << (int)c << " ";
  20. }
  21. cout << endl;
  22. return 0;
  23. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
b 7c 28 c9 b7 29 c 98 d7 43 8e 70 b3 d3 f7 c8 48 fb d7 d1 dc 19 4f f8 3f 4f 7c c9 b1 37 8e 98