fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4. #include <vector>
  5. using namespace std;
  6.  
  7. vector<unsigned char> hexToByteArray(string input_hash)
  8. {
  9. vector<unsigned char> byteArray;
  10. for (unsigned int i = 0; i < input_hash.length(); i += 2)
  11. {
  12. string byteString = input_hash.substr(i, 2);
  13. unsigned char byte = (unsigned char) strtol(byteString.c_str(), NULL, 16);
  14. byteArray.push_back(byte);
  15. }
  16. return byteArray;
  17. }
  18.  
  19. int main(int argc, char* argv[])
  20. {
  21. string input_hash;
  22. if(argc>1)
  23. {
  24. input_hash=argv[1];
  25. }
  26. else
  27. {
  28. cout<<"Enter the input hash:";input_hash;
  29. }
  30. vector<unsigned char> byte_array = hexToByteArray(input_hash);
  31. vector<int> frequencies;
  32.  
  33. for (unsigned int i = 0; i < byte_array.size(); i++)
  34. {
  35. int frequency = byte_array[i] * 20; // mapping each byte of RICK to a frequency
  36. frequencies.push_back(frequency);
  37. }
  38. cout<<"Frequency: ";
  39. for(int i=0;i<frequencies.size();i++)
  40. {
  41. cout<<frequencies[i]<<" ";
  42. }
  43. cout<<endl;
  44. return 0;
  45. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Enter the input hash:Frequency: