Created
March 26, 2014 22:21
-
-
Save azat/9794985 to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* @example 0x1122334455667788 => 0x4477225588336611 | |
* | |
* NB: Do not use this functin like a {cryptographic,} hash function | |
*/ | |
static inline uint64_t memfryu64(uint64_t a, u8 off) | |
{ | |
uint64_t b = 0; | |
for (u8 i = 0; i < sizeof(uint64_t); ++i) { | |
u8 aOff = (i + ((i % 2) ? 0 : off)) % sizeof(uint64_t); | |
b = (b << __CHAR_BIT__) | (u8)(a >> (__CHAR_BIT__ * aOff)); | |
} | |
return b; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment