Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Apr 10th, 2020 109 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string.h>
  4. using namespace std;
  5. //ceva gresit
  6. ifstream in("hex.in");
  7. ofstream out("hex.out");
  8.  
  9. char getB16Chr(int x)
  10. {
  11.     if(x <= 9)
  12.         return '0' + x;
  13.     else
  14.         return 'A' + x - 10;
  15. }
  16.  
  17. int main()
  18. {
  19.     char s[1100];
  20.    
  21.     cin.get(s,1050);
  22.    
  23.     int l = (int)strlen(s), nrGroup, rez;
  24.    
  25.     nrGroup = l % 4;
  26.    
  27.     if(nrGroup % 4 == 0)
  28.         nrGroup = 4;
  29.    
  30.     rez = 0;
  31.     for(int i=nrGroup-1,p = 1;i>=0;i--,p*=2)
  32.         rez += (s[i] - '0')*p;
  33.    
  34.     cout<<getB16Chr(rez);//clean left base
  35.    
  36.     for(int i = nrGroup;i<l;i+=4)
  37.     {
  38.         rez = (s[i] - '0') * 8 + (s[i + 1] - '0') * 4 + (s[i + 2] - '0') * 2 + (s[i + 3] - '0') ;
  39.         cout<<getB16Chr(rez);
  40.     }
  41.    
  42.    
  43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top