Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Mar 28th, 2020 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. char decrypt(unsigned char sym) // 1000 0000
  5. {
  6.     //01001000 => 72  & | ^ >> << ~
  7.     unsigned char first = 0xf0, second = 0x0f, F_left, F_right;
  8.     first = sym >> 4; // 1000
  9.     second &= sym; // 0000
  10.     second = first ^ second; // 1000
  11.     F_left = (first << 1) & 10;
  12.     F_right = (first >> 1) & 5;
  13.     first = F_left | F_right; // 0100
  14.     return sym = (first << 4) | second;
  15. }
  16.  
  17. unsigned char encrypt (unsigned char sym)
  18. {
  19.     //72 => 01001000 & | ^ >> << ~
  20.     unsigned char first = 0xf0, second = 0x0f, F_left, F_right;
  21.     first = sym >> 4; //0000 0100
  22.     second &= sym; //0000 1000
  23.     F_left = (first << 1) & 10; //0100 => 1000
  24.     F_right = (first >> 1) & 5; // 0100 => 0100
  25.     first = F_left | F_right; // 1000
  26.     second ^= first; // 0000
  27.     return sym = (first << 4) | second; // 1000 0000
  28. }
  29.  
  30. int main()
  31. {
  32.     unsigned char str[] = "Hello world!";
  33.     int i = 0;
  34.     /*changesym(strok);*/
  35.     while (str[i] != '\0')
  36.     {
  37.         str[i] = encrypt(str[i]);
  38.         printf("%X ", str[i]);
  39.         i++;
  40.     }
  41.     printf("\n");
  42.     i = 0;
  43.     while (str[i] != '\0')
  44.     {
  45.         str[i] = decrypt(str[i]);
  46.         printf("%c", str[i]);
  47.         i++;
  48.     }
  49.    
  50.  
  51.     /*printf("%s", strok);*/
  52.     return 0;
  53. }
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