Created
March 1, 2020 09:35
-
-
Save miura1729/37d4c1477cd04e394421cffd6a010e40 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
main() | |
{ | |
unsigned char base[] = {0x03, 0x10, 0x21, 0x44, 0xf0, 0xe1, 0x98, 0x21}; | |
unsigned char keys[8] = {0, 0, 0, 0, 0, 0, 0, 0}; | |
unsigned char key = 0xf0; | |
unsigned char kt; | |
unsigned char tmp = 0xff; | |
int i; | |
int j; | |
for (i = 0; i < 8; i++) { | |
for (j = 0; j < 8; j++) { | |
keys[i] |= (base[j] & (1 << i) ? 1 << j : 0); | |
} | |
} | |
printf("%x \n", keys[0]); | |
printf("%x \n", keys[1]); | |
printf("%x \n", keys[2]); | |
printf("%x \n", keys[3]); | |
kt = key; | |
tmp &= (keys[0] ^ ~(-(kt & 1))); | |
kt >>= 1; | |
tmp &= (keys[1] ^ ~(-(kt & 1))); | |
kt >>= 1; | |
tmp &= (keys[2] ^ ~(-(kt & 1))); | |
kt >>= 1; | |
tmp &= (keys[3] ^ ~(-(kt & 1))); | |
kt >>= 1; | |
tmp &= (keys[4] ^ ~(-(kt & 1))); | |
kt >>= 1; | |
tmp &= (keys[5] ^ ~(-(kt & 1))); | |
kt >>= 1; | |
tmp &= (keys[6] ^ ~(-(kt & 1))); | |
kt >>= 1; | |
tmp &= (keys[7] ^ ~(-(kt & 1))); | |
kt >>= 1; | |
printf("%x \n", tmp); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment