Created
November 2, 2012 18:04
-
-
Save 1mentat/4003240 to your computer and use it in GitHub Desktop.
dual 28 bit rotation
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 <stdint.h> | |
#include <stdio.h> | |
int | |
main() | |
{ | |
uint64_t item = 0x00a5a5a5a5a5a5a5; | |
uint64_t mask_upper = 0x00fffffff0000000; | |
uint64_t mask_lower = 0x000000000fffffff; | |
uint64_t mask_bits = 0x0000000010000001; | |
uint64_t bits = 0x0000000000000000; | |
int i; | |
printf("0x%llx 0x%llx\n", ((item & mask_upper) >> 28), item & mask_lower); | |
for (i = 0; i < 56; i++) | |
{ | |
bits = item & mask_bits; | |
item >>= 1; | |
bits <<= 27; | |
item &= ~(mask_bits << 27); | |
item |= bits; | |
printf("rotate: %d 0x%llx 0x%llx\n", i, ((item & mask_upper) >> 28), item & mask_lower); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment